From 34d1a0ae8965e900b994b8a1842fa3c8ec65221a Mon Sep 17 00:00:00 2001 From: Charlotte Wickham Date: Wed, 15 Apr 2026 11:31:18 -0700 Subject: [PATCH] Fix preview links showing unrelated content changes Diff against the merge commit's first parent (HEAD~1) instead of origin/main. The merge ref can be stale when main moves forward, causing files added to main after the PR was opened to appear in the preview links. --- .github/workflows/deploy-preview.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index 1b040f8c2..09709359a 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -122,8 +122,10 @@ jobs: - name: Detect content changes id: detect-content run: | - git fetch origin main --depth=1 - CHANGED=$(git diff --name-only origin/main -- 'content/' \ + # HEAD is refs/pull/N/merge — a merge commit whose first parent is + # the base branch. Diffing against HEAD~1 gives exactly the PR's + # changes, even when main has moved ahead of the merge ref. + CHANGED=$(git diff --name-only HEAD~1 -- 'content/' \ | { grep -E '/_?index\.(md|qmd|ipynb|Rmd|Rmarkdown|markdown|html)$' || true; }) if [ -z "$CHANGED" ]; then