Skip to content

Commit 4851b90

Browse files
authored
Merge pull request #65 from cardmagic/fix/context7-refresh-too-early
ci: treat a too-early Context7 refresh as a skip
2 parents befffef + 8362900 commit 4851b90

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" ] && jq -e '.error == "too-early"' response.json > /dev/null; 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)