From 76bd0bc0b1f2a0a942dd4301b80a5d4b877cc582 Mon Sep 17 00:00:00 2001 From: Arcadiy Ivanov Date: Wed, 8 Apr 2026 12:56:58 -0400 Subject: [PATCH] Ping IndexNow crawlers after GitHub Pages deployment Add a workflow that triggers after the pages-build-deployment completes successfully, fetches the live sitemap, and submits all page URLs to IndexNow (Bing, Yandex, Naver, Seznam, Yep). Google deprecated their ping endpoint in 2023 and offers no CI-callable alternative. --- .github/workflows/ping-indexnow.yml | 18 +++++++++ _config.yml | 1 + f70e81d625534adb96e7e8d5bd0b438b.txt | 1 + ping-indexnow.sh | 55 ++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 .github/workflows/ping-indexnow.yml create mode 100644 f70e81d625534adb96e7e8d5bd0b438b.txt create mode 100755 ping-indexnow.sh diff --git a/.github/workflows/ping-indexnow.yml b/.github/workflows/ping-indexnow.yml new file mode 100644 index 0000000..c22ed34 --- /dev/null +++ b/.github/workflows/ping-indexnow.yml @@ -0,0 +1,18 @@ +name: Ping IndexNow +on: + workflow_run: + workflows: ["pages-build-deployment"] + types: + - completed +jobs: + ping: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + ref: source + - name: Fetch live sitemap and ping IndexNow + run: | + curl -sf -o sitemap.xml https://pybuilder.io/sitemap.xml + $GITHUB_WORKSPACE/ping-indexnow.sh sitemap.xml f70e81d625534adb96e7e8d5bd0b438b diff --git a/_config.yml b/_config.yml index 5becf05..1d21be3 100644 --- a/_config.yml +++ b/_config.yml @@ -30,6 +30,7 @@ include: - .nojekyll exclude: - build.sh + - ping-indexnow.sh - deploy.key - deploy.key.enc twitter: diff --git a/f70e81d625534adb96e7e8d5bd0b438b.txt b/f70e81d625534adb96e7e8d5bd0b438b.txt new file mode 100644 index 0000000..ad6d36d --- /dev/null +++ b/f70e81d625534adb96e7e8d5bd0b438b.txt @@ -0,0 +1 @@ +f70e81d625534adb96e7e8d5bd0b438b diff --git a/ping-indexnow.sh b/ping-indexnow.sh new file mode 100755 index 0000000..58b2ef4 --- /dev/null +++ b/ping-indexnow.sh @@ -0,0 +1,55 @@ +#!/bin/bash -eEu + +# Ping IndexNow with all URLs from the sitemap. +# IndexNow distributes to Bing, Yandex, Naver, Seznam, and Yep. +# Google does not participate in IndexNow (deprecated their ping endpoint in 2023). + +SITEMAP_FILE="${1:?Usage: $0 }" +INDEXNOW_KEY="${2:?Usage: $0 }" +SITE_HOST="pybuilder.io" + +# Extract URLs from sitemap XML +URLS=$(python3 -c " +import xml.etree.ElementTree as ET +tree = ET.parse('$SITEMAP_FILE') +ns = {'s': 'http://www.sitemaps.org/schemas/sitemap/0.9'} +for loc in tree.findall('.//s:loc', ns): + print(loc.text) +") + +if [ -z "$URLS" ]; then + echo "No URLs found in sitemap" + exit 1 +fi + +URL_COUNT=$(echo "$URLS" | wc -l) +echo "Submitting $URL_COUNT URLs to IndexNow" + +# Build JSON URL list +URL_JSON=$(echo "$URLS" | python3 -c " +import sys, json +urls = [line.strip() for line in sys.stdin if line.strip()] +print(json.dumps(urls)) +") + +RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "https://api.indexnow.org/indexnow" \ + -H "Content-Type: application/json; charset=utf-8" \ + -d "{ + \"host\": \"$SITE_HOST\", + \"key\": \"$INDEXNOW_KEY\", + \"keyLocation\": \"https://$SITE_HOST/$INDEXNOW_KEY.txt\", + \"urlList\": $URL_JSON + }") + +HTTP_CODE=$(echo "$RESPONSE" | tail -1) +BODY=$(echo "$RESPONSE" | head -n -1) + +echo "IndexNow response: HTTP $HTTP_CODE" +if [ -n "$BODY" ]; then + echo "$BODY" +fi + +case "$HTTP_CODE" in + 200|202) echo "IndexNow submission accepted" ;; + *) echo "IndexNow submission failed"; exit 1 ;; +esac