Skip to content

ci: fail when routing artifacts drift from content/blog - #272

Merged
saiyam1814 merged 1 commit into
mainfrom
ci/routing-artifact-drift-guard
Sep 16, 2026
Merged

saiyam1814 merged 1 commit into
mainfrom
ci/routing-artifact-drift-guard

Conversation

@saiyam1814

Copy link
Copy Markdown
Member

Follow-up to #271, which fixed the drift by hand. This stops it recurring.

The problem

scripts/generate-redirects.mjs writes four files: public/_redirects, public/_worker.js, public/_routes.json, vercel.json. prebuild regenerates all four during every Pages build, so a stale committed copy never breaks the live site. That is exactly what makes the drift invisible — there is no symptom to notice.

It slipped through twice:

post missing from
kubernetes-observability-in-2026-with-openobserve (#268) all four files
inside-kueue-how-kubernetes-decides-what-runs-next (#266) _worker.js

_worker.js is the one that matters most — it holds BLOG_SLUGS and does the actual routing on Cloudflare ("Pages picks _worker.js over _redirects when both exist"). Both omissions were only found by regenerating and diffing by hand.

The guard

One step in Node.js CI, after npm ci and before npm run build: regenerate, and fail if the tree changed.

::error::Routing artifacts are stale. Run 'npm run blog:redirects' and commit the result.

Fails fast, before the build, and names the fix in the error.

Verified both directions

A guard that cannot fail is worthless, so I checked it actually trips:

  • No diff on current main — the generator is deterministic; git diff --quiet over the four paths exits clean on 0629337.
  • Trips on a new post — dropping one markdown file into content/blog takes it 203 → 204 slugs and the guard reports DIRTY. Simulation cleaned up afterwards; this PR touches only the workflow.

This PR's own CI run exercises the new step.

Why not .gitignore instead

vercel.json is read by the Vercel platform before the build runs, so it has to stay committed. Once one of the four must be tracked, keeping all four consistent and checked is simpler than splitting the rules.

🤖 Generated with Claude Code

scripts/generate-redirects.mjs writes public/_redirects, public/_worker.js,
public/_routes.json and vercel.json. prebuild regenerates all four during every
Pages build, so a stale committed copy never breaks the live site -- which is
precisely why the drift is invisible.

It went unnoticed twice: #268 was missing from all four files, and #266 was
missing from _worker.js (the file that actually holds BLOG_SLUGS and does the
routing on Cloudflare). Both were only found by regenerating and diffing by hand.

This regenerates in CI and fails if the tree changes, with a message naming the
fix. Verified both ways: no diff on current main, and adding one post to
content/blog trips it (203 -> 204 slugs).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying website with  Cloudflare Pages  Cloudflare Pages

Latest commit: a893abb
Status: ✅  Deploy successful!
Preview URL: https://3b7ec121.website-dab.pages.dev
Branch Preview URL: https://ci-routing-artifact-drift-gu.website-dab.pages.dev

View logs

@saiyam1814
saiyam1814 merged commit b79322f into main Sep 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant