Files
LangBot/.github/workflows/context7-refresh.yml
RockChinQandClaude Opus 5.5 55be792a3d fix(ci): restore i18n key parity and tolerate Context7 refresh cooldown (#2883)
- Add the workspace operation and assistant workspace-tool strings missing
  from zh-Hant, ja-JP, es-ES, ru-RU, th-TH and vi-VN, so the i18n key check
  passes again.
- Treat Context7's "too-early" refresh reply as a skipped refresh rather
  than a failure; the next docs push after the cooldown refreshes again.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 17:06:11 +08:00

61 lines
2.2 KiB
YAML

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"
# Context7 rate-limits refreshes per library; the next docs push after
# the window refreshes again, so a too-early reply is not a failure.
if [ "$code" = "400" ] && grep -q '"too-early"' "$RUNNER_TEMP/refresh.json"; then
echo "::warning::Context7 refresh skipped: the library was refreshed recently."
exit 0
fi
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}."