From c29cc28d7c50d0390bea843643fe3446389cda55 Mon Sep 17 00:00:00 2001 From: Ivo Date: Sat, 4 Jul 2026 16:38:24 +0200 Subject: [PATCH] ci: verify the Pages deployment actually serves the new build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The build-and-deploy check could pass while the preview stayed stale: pushing to gh-pages succeeds, but GitHub's own Pages publish step can fail transiently afterwards — and it does not auto-retry, so the site keeps serving the previous artifact under a green check. The artifact now carries a build-id stamp, and a verify step polls the deployed URL (PR subdirectory or root) until it serves this run's stamp, failing loudly after ~10 minutes with recovery instructions. Green now means live. Co-Authored-By: Claude Fable 5 --- .github/workflows/deploy-storybook.yml | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/deploy-storybook.yml b/.github/workflows/deploy-storybook.yml index 4e995259..05f0db3f 100644 --- a/.github/workflows/deploy-storybook.yml +++ b/.github/workflows/deploy-storybook.yml @@ -48,6 +48,11 @@ jobs: - name: Build Storybook run: pnpm --filter @unlayer/react-elements run build-storybook + # Stamp the artifact so the verify step can prove THIS build is the + # one being served — not a stale previous deploy. + - name: Stamp build id + run: echo "${{ github.run_id }}" > packages/react/storybook-static/build-id.txt + # Get the GitHub Pages URL dynamically - name: Get Pages URL id: pages @@ -87,6 +92,29 @@ jobs: if: github.event_name == 'pull_request' run: echo "::notice::Storybook preview deployed to ${{ steps.pages.outputs.url }}pr/${{ github.event.pull_request.number }}/" + # The green check must mean "this exact build is being served" — the + # push to gh-pages can succeed while GitHub's own Pages publish fails + # transiently (and it does not auto-retry), silently serving a stale + # preview. Poll the deployed build stamp until it matches this run. + - name: Verify deployment is live + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + TARGET="${{ steps.pages.outputs.url }}pr/${{ github.event.pull_request.number }}/build-id.txt" + else + TARGET="${{ steps.pages.outputs.url }}build-id.txt" + fi + echo "Verifying $TARGET serves build ${{ github.run_id }}" + for i in $(seq 1 40); do + LIVE=$(curl -fs -H 'Cache-Control: no-cache' "$TARGET?cb=${{ github.run_id }}-$i" || true) + if [ "$LIVE" = "${{ github.run_id }}" ]; then + echo "Live after ~$((i * 15))s" + exit 0 + fi + sleep 15 + done + echo "::error::Pages never served this build (currently serving: '${LIVE:-nothing}'). GitHub's Pages publish likely failed — re-run this workflow, or trigger a rebuild with: gh api -X POST repos/${{ github.repository }}/pages/builds" + exit 1 + - name: Add Storybook link to PR description if: github.event_name == 'pull_request' uses: actions/github-script@v7