feat(seo): IndexNow post-deploy submission to Bing/Yandex/Naver #20
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
| # .github/workflows/pages.yml — Deploy site/ to GitHub Pages | |
| # Copy this file to each repo's .github/workflows/ directory | |
| name: Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "site/**" | |
| - ".github/workflows/pages.yml" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Vendor shared assets (sync-assets) | |
| run: node node_modules/@grainulation/barn/tools/sync-assets.js --target ./site --verbose | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: site | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| - name: Notify IndexNow | |
| if: success() | |
| env: | |
| HOST: mill.grainulation.com | |
| INDEXNOW_KEY: 7100366149211580be04515b58b6e6d0 | |
| run: | | |
| set -u | |
| sleep 15 | |
| URLS=$(curl -sSf "https://$HOST/sitemap.xml" | grep -oE '<loc>[^<]+</loc>' | sed -E 's/<\/?loc>//g' || true) | |
| if [ -z "$URLS" ]; then | |
| echo "No URLs extracted from sitemap — skipping IndexNow submission" | |
| exit 0 | |
| fi | |
| PAYLOAD=$(HOST="$HOST" KEY="$INDEXNOW_KEY" URLS="$URLS" node -e ' | |
| const host = process.env.HOST; | |
| const key = process.env.KEY; | |
| const urlList = process.env.URLS.split(/\s+/).filter(Boolean); | |
| process.stdout.write(JSON.stringify({ | |
| host, key, | |
| keyLocation: `https://${host}/${key}.txt`, | |
| urlList | |
| })); | |
| ') | |
| COUNT=$(echo "$URLS" | wc -l | tr -d ' ') | |
| echo "Submitting $COUNT URLs to IndexNow for $HOST" | |
| HTTP_CODE=$(curl -sS -o /tmp/indexnow-resp.txt -w "%{http_code}" \ | |
| -X POST -H "Content-Type: application/json" \ | |
| -d "$PAYLOAD" https://api.indexnow.org/indexnow || echo "000") | |
| echo "IndexNow response: $HTTP_CODE" | |
| cat /tmp/indexnow-resp.txt || true | |
| case "$HTTP_CODE" in | |
| 200|202) echo "OK" ;; | |
| *) echo "::warning::IndexNow returned $HTTP_CODE — not blocking deploy" ;; | |
| esac |