Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
yml 199 lines 7.2 KB
Raw
1 name: Docs - Repair KB Semantic Artifact
2
3 # KB guides are published by the support portal through docs-kb-publish.yml.
4 # This six-hour run repairs kb/semantic-index.json when docs or guide changes
5 # landed on next without a rebuild (fork PRs, or a publication that merged
6 # before docs-rebuild-kb-semantic.yml finished).
7 on:
8 schedule:
9 - cron: '17 */6 * * *'
10 workflow_dispatch:
11
12 permissions:
13 contents: read
14
15 concurrency:
16 # Shared with portal publications so each run starts from a settled next.
17 group: docs-kb-publication
18 cancel-in-progress: false
19 queue: max
20
21 jobs:
22 refresh:
23 runs-on: ubuntu-latest
24 permissions:
25 contents: read
26 outputs:
27 docs_base_sha: ${{ steps.docs-base.outputs.sha }}
28 changed: ${{ steps.semantic.outputs.stale }}
29 defaults:
30 run:
31 working-directory: ./docs
32
33 steps:
34 - name: Checkout docs repository
35 uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
36 with:
37 ref: next
38 persist-credentials: false
39
40 - name: Record docs base
41 id: docs-base
42 run: |
43 docs_base_sha=$(git rev-parse HEAD)
44 echo "sha=$docs_base_sha" >> "$GITHUB_OUTPUT"
45
46 - name: Setup Node.js, pnpm, Bun
47 uses: ./.github/actions/setup-node-pnpm-bun
48
49 - name: Cache Bun dependencies
50 uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
51 with:
52 path: ~/.bun/install/cache
53 key: ${{ runner.os }}-bun-${{ hashFiles('docs/bun.lock') }}
54 restore-keys: |
55 ${{ runner.os }}-bun-
56
57 - name: Install dependencies
58 run: bun install
59
60 - name: Detect stale semantic artifact
61 id: semantic
62 run: |
63 if bun scripts/build-kb-semantic-index.ts --check; then
64 echo "stale=false" >> "$GITHUB_OUTPUT"
65 else
66 echo "stale=true" >> "$GITHUB_OUTPUT"
67 echo "Semantic artifact is stale against the checked-in docs corpus."
68 fi
69
70 - name: Rebuild generated pages and semantic artifact
71 if: steps.semantic.outputs.stale == 'true'
72 env:
73 OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
74 run: bun run build:kb-semantic
75
76 - name: Verify rebuilt semantic artifact
77 if: steps.semantic.outputs.stale == 'true'
78 run: bun run check:kb-semantic
79
80 - name: Upload verified semantic artifact
81 if: steps.semantic.outputs.stale == 'true'
82 uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
83 with:
84 name: kb-semantic-repair
85 path: docs/kb/semantic-index.json
86 if-no-files-found: error
87 retention-days: 1
88
89 propose:
90 needs: refresh
91 if: needs.refresh.outputs.changed == 'true'
92 runs-on: ubuntu-latest
93 permissions:
94 contents: read
95
96 steps:
97 - name: Checkout docs repository
98 uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
99 with:
100 # Apply the artifacts relative to the exact tree that produced them.
101 ref: ${{ needs.refresh.outputs.docs_base_sha }}
102 persist-credentials: false
103
104 - name: Download verified semantic artifact
105 uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
106 with:
107 name: kb-semantic-repair
108 path: docs/kb
109
110 - name: Generate composio PR token
111 id: write-token
112 uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
113 with:
114 client-id: ${{ vars.RELEASE_BOT_CLIENT_ID }}
115 private-key: ${{ secrets.RELEASE_BOT_APP_PRIVATE_KEY }}
116 owner: ComposioHQ
117 repositories: composio
118 permission-contents: write
119 permission-pull-requests: write
120
121 - name: Create repair pull request
122 uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3
123 with:
124 token: ${{ steps.write-token.outputs.token }}
125 commit-message: 'docs(kb): rebuild stale semantic artifact'
126 title: 'docs(kb): rebuild stale semantic artifact'
127 body: |
128 Automated rebuild of `docs/kb/semantic-index.json` after docs or KB guide changes landed on `next` without one.
129
130 - Reused unchanged vectors and embedded only changed records
131 - Verified semantic artifact against the checked-in corpus
132 branch: docs/auto-update-kb
133 base: next
134 add-paths: docs/kb/semantic-index.json
135
136 # Rebuild and PR creation are one pipeline. Report after both jobs so a
137 # successful rebuild cannot hide a failed proposal, and close the issue only
138 # after every required stage has recovered.
139 report:
140 needs: [refresh, propose]
141 if: always()
142 runs-on: ubuntu-latest
143 permissions:
144 issues: write
145
146 steps:
147 - name: Open KB repair failure issue
148 if: needs.refresh.result == 'failure' || needs.propose.result == 'failure'
149 continue-on-error: true
150 env:
151 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152 GH_REPO: ${{ github.repository }}
153 LABEL: docs-kb-refresh-failure
154 RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
155 EVENT_NAME: ${{ github.event_name }}
156 REFRESH_RESULT: ${{ needs.refresh.result }}
157 PROPOSE_RESULT: ${{ needs.propose.result }}
158 run: |
159 gh label create "$LABEL" \
160 --color B60205 \
161 --description "Scheduled KB semantic artifact repair is failing" 2>/dev/null || true
162
163 existing=$(gh issue list --label "$LABEL" --state open --limit 1 \
164 --json number --jq '.[0].number // empty')
165 if [ -n "$existing" ]; then
166 echo "Issue #$existing is already open for this failure; not filing a duplicate."
167 exit 0
168 fi
169
170 gh issue create \
171 --title "KB semantic artifact repair is failing" \
172 --label "$LABEL" \
173 --body "The scheduled KB semantic artifact repair failed.
174
175 - Run: $RUN_URL
176 - Trigger: \`$EVENT_NAME\`
177 - Rebuild job: \`$REFRESH_RESULT\`
178 - Proposal job: \`$PROPOSE_RESULT\`
179
180 **Impact:** KB search answers new or changed content with keyword results
181 only until this workflow recovers.
182
183 **First checks:** verify that \`OPENAI_API_KEY\` is set and that the Release
184 Bot GitHub App can write the repair branch and PR in \`ComposioHQ/composio\`."
185
186 - name: Close KB repair failure issue
187 if: needs.refresh.result == 'success' && (needs.refresh.outputs.changed != 'true' || needs.propose.result == 'success')
188 continue-on-error: true
189 env:
190 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
191 GH_REPO: ${{ github.repository }}
192 LABEL: docs-kb-refresh-failure
193 run: |
194 existing=$(gh issue list --label "$LABEL" --state open --limit 1 \
195 --json number --jq '.[0].number // empty')
196 if [ -n "$existing" ]; then
197 gh issue close "$existing" \
198 --comment "The KB semantic artifact repair recovered in run ${{ github.run_id }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}."
199 fi