-
Notifications
You must be signed in to change notification settings - Fork 2
79 lines (72 loc) · 2.61 KB
/
Copy pathcontext7-refresh.yml
File metadata and controls
79 lines (72 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Refresh Context7 Docs
on:
push:
branches:
- main
paths:
- ".github/workflows/context7-refresh.yml"
- "README.md"
- "api.md"
- "context7.json"
- "package.json"
- "examples/**"
workflow_dispatch:
permissions: {}
concurrency:
group: context7-refresh-${{ github.ref }}
cancel-in-progress: true
jobs:
refresh:
name: Refresh Context7
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Trigger Context7 refresh
env:
CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }}
run: |
set -euo pipefail
if [ -z "$CONTEXT7_API_KEY" ]; then
echo "::warning ::CONTEXT7_API_KEY is missing. Add the secret to refresh Context7 automatically."
exit 0
fi
body_file="$(mktemp)"
trap 'rm -f "$body_file"' EXIT
status="$(curl --connect-timeout 10 --max-time 30 --proto '=https' -sS --tlsv1.2 -o "$body_file" -w "%{http_code}" -X POST "https://context7.com/api/v1/refresh" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${CONTEXT7_API_KEY}" \
-d '{"libraryName": "/xquik-dev/x-twitter-scraper-typescript"}')"
case "$status" in
200|202)
cat "$body_file"
;;
400)
if grep -Eiq "active-task|being processed|already.*process" "$body_file"; then
echo "::warning ::Context7 is processing another library. Retry after the next docs change."
cat "$body_file"
elif grep -Eiq "too-early|minimum .* days|required between updates" "$body_file"; then
echo "::warning ::Context7 refresh is not due yet."
cat "$body_file"
else
echo "::error ::Context7 refresh returned HTTP $status. Review the response."
cat "$body_file"
exit 1
fi
;;
404)
echo "::warning ::Context7 library /xquik-dev/x-twitter-scraper-typescript is unavailable. Wait for initial indexing."
cat "$body_file"
;;
401|403)
echo "::error ::Context7 authentication failed. Check CONTEXT7_API_KEY."
exit 1
;;
429)
echo "::warning ::Context7 rate-limited this refresh. Retry after the next docs change."
;;
*)
echo "::error ::Context7 refresh returned HTTP $status. Review the response."
cat "$body_file"
exit 1
;;
esac