-
Notifications
You must be signed in to change notification settings - Fork 19
104 lines (89 loc) · 3.27 KB
/
Copy pathindex-main-content.yml
File metadata and controls
104 lines (89 loc) · 3.27 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Index Main Content
on:
push:
branches:
- main
paths:
- "content/docs.yml"
- "content/remote-specs.json"
- "src/openapi/**"
- "src/openrpc/**"
repository_dispatch:
types: [remote-spec-updated]
workflow_dispatch: {}
jobs:
index-main:
name: Index and sync main content
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: ./.github/actions/setup-pnpm
- name: Generate API specs
run: pnpm generate
- name: Upload specs to Redis
run: pnpm upload-specs
env:
KV_REST_API_URL: ${{ secrets.KV_REST_API_URL }}
KV_REST_API_TOKEN: ${{ secrets.KV_REST_API_TOKEN }}
- name: Run main content indexer
run: pnpm index:main
env:
KV_REST_API_TOKEN: ${{ secrets.KV_REST_API_TOKEN }}
KV_REST_API_URL: ${{ secrets.KV_REST_API_URL }}
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_ADMIN_API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }}
- name: Revalidate docs index and nav caches
run: |
echo "Revalidating docs index and navigation caches..."
# Extract tab IDs from docs.yml (these are the nav tree keys)
NAV_TREES=$(yq -o=json '.tabs | keys' content/docs.yml)
echo "Nav trees to revalidate: $NAV_TREES"
# Create JSON payload using jq
PAYLOAD=$(jq -n \
--argjson navTrees "$NAV_TREES" \
'{pathIndices: ["docs"], navTrees: $navTrees}')
echo "Payload: $PAYLOAD"
# Call revalidation API
HTTP_CODE=$(curl -X POST "${{ secrets.DOCS_SITE_URL }}/api/revalidate/indices" \
-H "Authorization: Bearer ${{ secrets.DOCS_SITE_API_KEY }}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" \
--max-time 30 \
--fail-with-body \
-o response.json \
-w "%{http_code}" \
-s)
echo ""
echo "Response (HTTP $HTTP_CODE):"
jq '.' response.json || cat response.json
# Check HTTP status
if [ "$HTTP_CODE" != "200" ]; then
echo "::error::Indices revalidation API returned status $HTTP_CODE"
exit 1
fi
# Check success field in response
SUCCESS=$(jq -r '.success' response.json)
if [ "$SUCCESS" != "true" ]; then
echo "::warning::Revalidation completed with errors"
jq -r '.errors[]?' response.json
else
echo "::notice::✅ Successfully revalidated docs index and nav trees"
fi
- name: Revalidate changed specs
run: |
CHANGED=$(cat content/api-specs/changed-specs.json)
if [ "$CHANGED" = "[]" ]; then
echo "No spec changes to revalidate"
exit 0
fi
PAYLOAD=$(jq -n --argjson ids "$CHANGED" '{specIds: $ids}')
curl -X POST "${{ secrets.DOCS_SITE_URL }}/api/revalidate/specs" \
-H "Authorization: Bearer ${{ secrets.DOCS_SITE_API_KEY }}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" \
--max-time 120 \
--fail-with-body