Skip to content

Commit 93d09e1

Browse files
committed
build: ping indexnow with the deployed urls on every web deploy
1 parent 88f79c1 commit 93d09e1

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

.github/workflows/deploy-web.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,20 @@ jobs:
5252
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
5353
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
5454
run: bunx wrangler@4 pages deploy dist --project-name=bunmaska --branch=main
55+
56+
# IndexNow: one ping tells Bing (and the AI surfaces riding its index -
57+
# Copilot, partly ChatGPT), Yandex, Naver etc. the site changed. Google
58+
# does not participate - the sitemap covers it. Key file lives in public/.
59+
- name: Ping IndexNow with the deployed URLs
60+
run: |
61+
KEY=$(ls dist | grep -E '^[0-9a-f]{32}\.txt$' | head -1 | sed 's/\.txt$//')
62+
grep -oh '<loc>[^<]*' dist/sitemap-*.xml | sed 's/<loc>//' | grep -v '\.xml$' > /tmp/urls.txt
63+
COUNT=$(wc -l < /tmp/urls.txt | tr -d ' ')
64+
python3 -c "
65+
import json, sys
66+
urls = open('/tmp/urls.txt').read().split()
67+
print(json.dumps({'host': 'bunmaska.org', 'key': '$KEY', 'keyLocation': f'https://bunmaska.org/$KEY.txt', 'urlList': urls}))
68+
" > /tmp/indexnow.json
69+
curl -s -w "IndexNow HTTP %{http_code} ($COUNT urls)\n" -o /dev/null \
70+
-X POST -H "Content-Type: application/json" \
71+
--data @/tmp/indexnow.json https://api.indexnow.org/indexnow
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3ba465176f894b01a3fe04195ca9f620

0 commit comments

Comments
 (0)