Skip to content

Commit 8ef3856

Browse files
committed
ci: treat a too-early Context7 refresh as a skip
The first run of the refresh workflow failed. curl timed out after 60 seconds with no response, and later calls returned HTTP 400 {"error":"too-early","message":"... Minimum 10 days required between updates."}. Context7 limits how often one library refreshes, so the workflow failed on most pushes to main. Allow 180 seconds for the response, print the body, and end with a workflow notice when Context7 answers too-early. Any other non-200 answer still fails the job. Against the live API, the old script exited 56 on the too-early answer and the new script exits 0 with the notice.
1 parent f993409 commit 8ef3856

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎.github/workflows/context7-refresh.yml‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,19 @@ jobs:
2323
CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }}
2424
LIBRARY_NAME: /${{ github.repository }}
2525
run: |
26-
curl --fail --silent --show-error --max-time 60 \
26+
status=$(curl --silent --show-error --max-time 180 --output response.json --write-out '%{http_code}' \
2727
-X POST https://context7.com/api/v1/refresh \
2828
-H "Content-Type: application/json" \
2929
-H "Authorization: Bearer $CONTEXT7_API_KEY" \
30-
-d "{\"libraryName\": \"$LIBRARY_NAME\"}"
30+
-d "{\"libraryName\": \"$LIBRARY_NAME\"}")
31+
cat response.json
32+
echo
33+
if [ "$status" = "200" ]; then
34+
exit 0
35+
fi
36+
if [ "$status" = "400" ] && grep -q '"error":"too-early"' response.json; then
37+
echo "::notice::Context7 refreshed $LIBRARY_NAME recently, so it skipped this refresh."
38+
exit 0
39+
fi
40+
echo "::error::Context7 refresh failed with HTTP $status."
41+
exit 1

0 commit comments

Comments
 (0)