From 168528027b14db2808bb39db3c98786312aaf210 Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Thu, 18 Jun 2026 16:14:09 -0700 Subject: [PATCH 1/2] preview.yml: write PR metadata after checkout so it survives git clean MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Save PR metadata" step ran before `actions/checkout@v5`, whose default `clean: true` runs `git clean -ffdx` and deletes untracked files in the workspace — including the `_preview_upload/` directory the metadata step had just created. As a result `_preview_upload/meta/{pr-number,action}.txt` never made it into the `pr-preview-site` artifact (only `site/`, staged after checkout, survived). Downstream, preview-deploy.yml's "Read PR metadata" then `cat`-ed missing files, leaving `pr-number`/`action` empty, so the deploy step's `if: steps.meta.outputs.action == 'deploy'` guard was false and the deploy was silently skipped — while the job still reported success. Net effect: every deploy-path (non-closed) PR preview stopped publishing, with green checks. Move the metadata step to run after checkout. It stays unguarded, so the 'closed'/remove path (which skips checkout) is unaffected. Co-Authored-By: Claude Opus 4.8 Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com> --- .github/workflows/preview.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 4d7b4cde01..6a50590292 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -42,18 +42,28 @@ jobs: contents: read steps: - - name: Save PR metadata - run: | - mkdir -p _preview_upload/meta - echo "${{ github.event.pull_request.number }}" > _preview_upload/meta/pr-number.txt - echo "${{ github.event.action == 'closed' && 'remove' || 'deploy' }}" > _preview_upload/meta/action.txt - - name: Check out repository if: github.event.action != 'closed' uses: actions/checkout@v5 with: submodules: recursive + # IMPORTANT: write the metadata AFTER checkout. actions/checkout runs + # `git clean -ffdx` (clean: true is the default), which deletes any + # untracked files already in the workspace — including a + # `_preview_upload/` directory created beforehand. With the metadata + # written before checkout, `_preview_upload/meta/` was wiped and never + # reached the artifact, so preview-deploy.yml read an empty pr-number, + # the deploy step's `action == 'deploy'` guard was false, and every + # deploy-path preview was silently skipped (the job still passed). + # For the 'closed'/remove event the checkout step is skipped, but this + # step is unguarded and still runs, so the remove path is unaffected. + - name: Save PR metadata + run: | + mkdir -p _preview_upload/meta + echo "${{ github.event.pull_request.number }}" > _preview_upload/meta/pr-number.txt + echo "${{ github.event.action == 'closed' && 'remove' || 'deploy' }}" > _preview_upload/meta/action.txt + - name: Set up Quarto if: github.event.action != 'closed' uses: quarto-dev/quarto-actions/setup@v2 From 723c972c39ac3e325b80a09a46ebd348013ec3e4 Mon Sep 17 00:00:00 2001 From: Douglas Ezra Morrison Date: Thu, 18 Jun 2026 16:29:04 -0700 Subject: [PATCH 2/2] preview-deploy.yml: fail loudly if PR metadata is missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Harden the "Read PR metadata" step so a missing pr-number.txt/action.txt errors out instead of producing empty outputs and exit 0. Previously a bare `$(cat missing)` inside `echo` left the outputs empty and the deploy step's `action == 'deploy'` guard silently false — the same silent-skip pathology the metadata-after-checkout fix addresses on the build side. This is a defensive net for any future corrupt/partial artifact. Co-Authored-By: Claude Opus 4.8 Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com> --- .github/workflows/preview-deploy.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml index 9699a18213..8d2b18e7da 100644 --- a/.github/workflows/preview-deploy.yml +++ b/.github/workflows/preview-deploy.yml @@ -60,9 +60,15 @@ jobs: - name: Read PR metadata id: meta + # Fail loudly if the metadata is missing. A bare `$(cat missing)` + # inside `echo` yields empty output and exit 0, so the step would + # "pass" with empty pr-number/action and the deploy would silently + # skip (the regression this workflow pair just recovered from). run: | - echo "pr-number=$(cat _preview_download/meta/pr-number.txt)" >> "$GITHUB_OUTPUT" - echo "action=$(cat _preview_download/meta/action.txt)" >> "$GITHUB_OUTPUT" + pr_number=$(cat _preview_download/meta/pr-number.txt) || { echo "::error::Missing pr-number.txt in preview artifact"; exit 1; } + action=$(cat _preview_download/meta/action.txt) || { echo "::error::Missing action.txt in preview artifact"; exit 1; } + echo "pr-number=$pr_number" >> "$GITHUB_OUTPUT" + echo "action=$action" >> "$GITHUB_OUTPUT" - name: Deploy PR Preview if: steps.meta.outputs.action == 'deploy'