From 7fad73008c92582c2583fa0cf089bda41796a652 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Mon, 26 Oct 2026 07:17:41 -0600 Subject: [PATCH] ci: don't fail preview builds on broken internal links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Short Summary (TL;DR) Preview builds now warn about broken internal links instead of failing, so a link to a post that isn't merged yet doesn't block the preview. The build in test.yml still fails on them. ## How This PR Solves The Issue `failOnBrokenLinks` is off when `PREVIEW_BUILD` is set, which the fork preview workflow now does, and on Cloudflare Pages builds of any branch other than `main`. This matches how textlint and prettier are already left out of previews. ## Manual Testing Instructions Run `PREVIEW_BUILD=true npm run build` with a broken internal link in a post, and check that it prints "Build continued with N broken links" and exits 0. Without the variable, the build fails. 🤖 Developed with assistance from [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Opus 5.5 --- .github/workflows/cloudflare-preview-forks-build.yml | 6 ++++-- astro.config.mjs | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cloudflare-preview-forks-build.yml b/.github/workflows/cloudflare-preview-forks-build.yml index 77c19eb6..6b444198 100644 --- a/.github/workflows/cloudflare-preview-forks-build.yml +++ b/.github/workflows/cloudflare-preview-forks-build.yml @@ -78,10 +78,12 @@ jobs: - name: Install dependencies run: npm ci - # textlint and prettier run in test.yml. They are left out here so a - # wording or formatting problem doesn't hold back the preview. + # textlint, prettier, and failing on broken links run in test.yml. They + # are left out here so those problems don't hold back the preview. - name: Build run: npm run build + env: + PREVIEW_BUILD: "true" - name: Save PR number run: echo "${{ github.event.pull_request.number }}" > dist/pr-number.txt diff --git a/astro.config.mjs b/astro.config.mjs index c3d22966..7e5dfcaa 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -77,7 +77,12 @@ export default defineConfig({ prefetch(), linkValidator({ checkExternal: false, - failOnBrokenLinks: true, + // Previews report broken links without failing, like textlint and + // prettier; the build in test.yml is the check that fails. + failOnBrokenLinks: !( + process.env.PREVIEW_BUILD || + (process.env.CF_PAGES && process.env.CF_PAGES_BRANCH !== "main") + ), exclude: ["/_astro/*", "/s/*", "/board", "/download/*"], }), ],