From 926f4162dd15e4b65a27467fd90e7d6024f200de Mon Sep 17 00:00:00 2001 From: RockChinQ Date: Tue, 27 Oct 2026 09:20:41 +0000 Subject: [PATCH] ci(context7): refresh the Context7 library when the English docs change Context7 only re-indexes on its own popularity schedule, which is why the existing /langbot-app/langbot-docs entry had already drifted before this migration. Add the refresh call documented in Context7's GitHub Actions integration so a docs change reaches the index on the same push. The job is inert until a CONTEXT7_API_KEY secret exists, so it cannot fail the build while the library registration is pending. Co-Authored-By: Mika (Multica) Co-authored-by: multica-agent --- .github/workflows/context7-refresh.yml | 54 ++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/context7-refresh.yml diff --git a/.github/workflows/context7-refresh.yml b/.github/workflows/context7-refresh.yml new file mode 100644 index 000000000..4f380df6c --- /dev/null +++ b/.github/workflows/context7-refresh.yml @@ -0,0 +1,54 @@ +name: Refresh Context7 docs + +# Re-index the public documentation in Context7 whenever the English docs change. +# Requires a repository secret CONTEXT7_API_KEY (context7.com/dashboard) and a +# Context7 library registered for this repository; both are one-time owner steps. +# Until the secret exists every run is a no-op instead of a failure. + +on: + push: + branches: [master] + paths: + - "docs/en/**" + - "context7.json" + - ".github/workflows/context7-refresh.yml" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: context7-refresh + cancel-in-progress: true + +jobs: + refresh: + name: Refresh Context7 library + runs-on: ubuntu-latest + timeout-minutes: 5 + env: + CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }} + CONTEXT7_LIBRARY: /langbot-app/langbot + steps: + - name: Skip when the Context7 API key is not configured + if: env.CONTEXT7_API_KEY == '' + run: | + echo "CONTEXT7_API_KEY is not configured; skipping the Context7 refresh." + echo "Add the secret and register the library, then re-run this workflow." + + - name: Trigger Context7 refresh + if: env.CONTEXT7_API_KEY != '' + run: | + set -euo pipefail + body=$(printf '{"libraryName":"%s"}' "$CONTEXT7_LIBRARY") + code=$(curl -sS -o "$RUNNER_TEMP/refresh.json" -w '%{http_code}' \ + -X POST https://context7.com/api/v1/refresh \ + -H 'Content-Type: application/json' \ + -H "Authorization: Bearer ${CONTEXT7_API_KEY}" \ + -d "$body") + cat "$RUNNER_TEMP/refresh.json" + if [ "$code" -lt 200 ] || [ "$code" -ge 300 ]; then + echo "Context7 refresh failed with HTTP $code" >&2 + exit 1 + fi + echo "Requested a refresh of ${CONTEXT7_LIBRARY}."