Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/preview-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading