diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 8e70623..e9f5dbf 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -20,6 +20,18 @@ warm_city_archives() { "$APP_DIR/logs/warm-cities.log" 2>&1 & } +# Notify IndexNow (Bing / DuckDuckGo / Yandex) of the site's URLs, but only when +# the set of pages actually changed (a new/removed city) — code-only deploys skip, +# so we don't re-blast ~14k URLs every push. Best-effort: never fails the deploy. +# Sourcing the env matches the key the running service serves at /{key}.txt. +ping_indexnow() { + echo "==> Pinging IndexNow (only if the URL set changed)" + ( set -a; . /etc/thermograph.env 2>/dev/null || true; set +a + base="${THERMOGRAPH_BASE_URL:-https://thermograph.org}" + cd "$APP_DIR/backend" && "$APP_DIR/.venv/bin/python" indexnow.py --if-changed "$base" + ) || echo "!! IndexNow ping failed (non-fatal)" >&2 +} + echo "==> Fetching $BRANCH" git fetch --prune origin "$BRANCH" git reset --hard "origin/$BRANCH" @@ -43,6 +55,7 @@ for i in $(seq 1 15); do if curl -fsS -o /dev/null "$url"; then echo "==> OK: $url is serving" warm_city_archives + ping_indexnow exit 0 fi sleep 1 diff --git a/deploy/thermograph.env.example b/deploy/thermograph.env.example index 7ba9934..8110015 100644 --- a/deploy/thermograph.env.example +++ b/deploy/thermograph.env.example @@ -23,5 +23,7 @@ THERMOGRAPH_BASE=/ # IndexNow key (Bing/DuckDuckGo/Yandex instant re-crawl). Auto-generated to # data/indexnow_key.txt on first use; set here to pin a specific key. #THERMOGRAPH_INDEXNOW_KEY= -# Public site URL the IndexNow CLI submits (`make indexnow`). +# Public site URL for IndexNow. The deploy hook auto-pings IndexNow after a +# successful deploy, but only when the URL set changed (a new/removed city), so +# code-only deploys don't resubmit. `make indexnow` forces a full submit. THERMOGRAPH_BASE_URL=https://thermograph.org