fix(ci): IndexNow URL extraction — use sed -E for the optional / in <… #108
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: Deploy Docs | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'apps/docs/**' | |
| - '.github/workflows/deploy-docs.yml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build Docusaurus | |
| working-directory: apps/docs | |
| run: pnpm build | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: apps/docs/build | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| permissions: | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| notify-search-engines: | |
| needs: deploy | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Ping IndexNow (Bing, Yandex) | |
| run: | | |
| set -euo pipefail | |
| KEY=00ead8a088444c033454e7c5d686592d | |
| HOST=awbx.github.io | |
| SITEMAP=https://awbx.github.io/fhir-dsl/sitemap.xml | |
| # Wait briefly for the deploy edge to flush, then extract URLs from sitemap. | |
| sleep 30 | |
| URLS=$(curl -sf "$SITEMAP" | grep -oE '<loc>[^<]+</loc>' | sed -E 's|</?loc>||g') | |
| if [ -z "$URLS" ]; then | |
| echo "No URLs found in sitemap; skipping IndexNow notify." | |
| exit 0 | |
| fi | |
| # Build the JSON payload (Bing IndexNow batch endpoint). | |
| URL_LIST=$(echo "$URLS" | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
| PAYLOAD=$(jq -n \ | |
| --arg host "$HOST" \ | |
| --arg key "$KEY" \ | |
| --arg keyLocation "https://$HOST/fhir-dsl/$KEY.txt" \ | |
| --argjson urls "$URL_LIST" \ | |
| '{host: $host, key: $key, keyLocation: $keyLocation, urlList: $urls}') | |
| echo "Notifying IndexNow with $(echo "$URL_LIST" | jq 'length') URLs." | |
| curl -sS -X POST "https://api.indexnow.org/IndexNow" \ | |
| -H "Content-Type: application/json; charset=utf-8" \ | |
| -H "Host: api.indexnow.org" \ | |
| --data "$PAYLOAD" \ | |
| -o /tmp/indexnow.txt -w "HTTP %{http_code}\n" || true | |
| cat /tmp/indexnow.txt 2>/dev/null || true |