Index Main Content #311
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |