From a893abbf45a95ea0604a643265eb95d1a86db65d Mon Sep 17 00:00:00 2001 From: Saiyam Pathak Date: Wed, 16 Sep 2026 18:36:03 +0530 Subject: [PATCH] ci: fail when routing artifacts drift from content/blog 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) --- .github/workflows/node.js.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index ab2b17fcf..3c12999b3 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -21,4 +21,16 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm ci + # Guard against the committed output of scripts/generate-redirects.mjs + # drifting from content/blog. `prebuild` regenerates these during every + # deploy, so stale copies never break the live site -- which is exactly + # why the drift goes unnoticed until someone diffs them by hand. + - name: Routing artifacts are in sync with content/blog + run: | + npm run blog:redirects + if ! git diff --quiet -- public/_redirects public/_worker.js public/_routes.json vercel.json; then + echo "::error::Routing artifacts are stale. Run 'npm run blog:redirects' and commit the result." + git diff --stat -- public/_redirects public/_worker.js public/_routes.json vercel.json + exit 1 + fi - run: npm run build