-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (71 loc) · 2.47 KB
/
context7-refresh.yml
File metadata and controls
77 lines (71 loc) · 2.47 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
name: Refresh Context7 Docs
on:
push:
branches:
- main
paths:
- ".github/workflows/context7-refresh.yml"
- "README.md"
- "api.md"
- "context7.json"
- "x_twitter_scraper.gemspec"
- "lib/**/*.rb"
- "docs/**"
- "examples/**"
- "rbi/**/*.rbi"
- "sig/**/*.rbs"
workflow_dispatch:
permissions: {}
jobs:
refresh:
runs-on: ubuntu-latest
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 secret is not configured. Configure it to enable automatic Context7 refreshes."
exit 0
fi
body_file="$(mktemp)"
trap 'rm -f "$body_file"' EXIT
status="$(curl -sS -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-ruby"}')"
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 already processing another library. Retry on 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."
cat "$body_file"
exit 1
fi
;;
404)
echo "::warning ::Context7 library /xquik-dev/x-twitter-scraper-ruby is not available yet. Add processing may still be pending."
cat "$body_file"
;;
401|403)
echo "::error ::Context7 authentication failed."
exit 1
;;
429)
echo "::warning ::Context7 refresh is rate limited. Retry on the next docs change."
;;
*)
echo "::error ::Context7 refresh returned HTTP $status."
cat "$body_file"
exit 1
;;
esac