From f301cb27f4aa267f75dbb86e15fb7703021873f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Doruk=20=C3=96zgen?= Date: Tue, 23 Jun 2026 20:14:37 +0300 Subject: [PATCH] fix(ci): warm the new tag on jsDelivr before notifying the backend The publish workflow failed at "Notify backend" on every run: it cut the tag, slept 5s, then asked the backend to refresh by that brand-new tag. jsDelivr hadn't pulled the cold tag from GitHub yet, so the backend's fetch timed out -> 502 -> `curl -fsS` exit 22. Poll jsDelivr for the new tag until it actually serves it (<=60s) before notifying, retry the backend POST a few times for any residual cold-edge race, and treat a final failure as a `::warning::` (non-fatal) since the backend's L2 TTL refresh still propagates the tag. Companion: fleetifydev/fleetify-monorepo widens the backend's forced-refresh fetch timeout so a cold pull no longer 502s. Co-Authored-By: Claude Opus 4.8 --- .github/workflows/publish.yml | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bf45261..4939b53 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -75,14 +75,37 @@ jobs: exit 0 fi # Purge @main too, so branch-tracking consumers get the fresh file and - # jsDelivr re-pulls from GitHub before the refresh below lands. + # jsDelivr re-pulls from GitHub. curl -fsS "https://purge.jsdelivr.net/gh/fleetifydev/models@main/dist/models.json" || true - sleep 5 + # The backend force-refreshes by fetching the just-cut tag from jsDelivr, + # which must have pulled it from GitHub first. A brand-new tag is cold, so + # a bare `sleep 5` raced the cold pull and the backend timed out -> 502. + # Warm the tag and wait until jsDelivr actually serves it before notifying. + TAG_URL="https://cdn.jsdelivr.net/gh/fleetifydev/models@${TAG}/dist/models.json" + for i in $(seq 1 15); do + if curl -fsS -o /dev/null "$TAG_URL"; then + echo "jsDelivr is serving ${TAG} (attempt ${i})." + break + fi + echo "Waiting for jsDelivr to propagate ${TAG} (attempt ${i})..." + sleep 4 + done # Pin the tag we just cut. NOTE: that tag push used the default # GITHUB_TOKEN, which by design does NOT trigger release.yml (GitHub # blocks workflow-token pushes from starting new runs), so the auto # path notifies here directly. release.yml stays for manual tags. - curl -fsS -X POST "$BACKEND_BASE_URL/api/internal/catalog/refresh" \ - -H "Authorization: Bearer $CATALOG_REFRESH_SECRET" \ - -H "Content-Type: application/json" \ - -d "{\"tag\":\"${TAG}\"}" + # Retry for any residual cold-edge race; a failed notify is non-fatal - + # the backend's L2 TTL refresh still picks up the new tag. + for i in $(seq 1 5); do + if curl -fsS -X POST "$BACKEND_BASE_URL/api/internal/catalog/refresh" \ + -H "Authorization: Bearer $CATALOG_REFRESH_SECRET" \ + -H "Content-Type: application/json" \ + -d "{\"tag\":\"${TAG}\"}"; then + echo "Backend pinned ${TAG}." + exit 0 + fi + echo "Backend refresh attempt ${i} failed; retrying in 5s..." + sleep 5 + done + echo "::warning::Backend catalog refresh did not succeed after retries; the L2 TTL refresh will still propagate ${TAG}." + exit 0