Skip to content
Merged
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
14 changes: 12 additions & 2 deletions .github/workflows/build-staged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,19 @@ jobs:
fi
echo "Commit message: $COMMIT_MESSAGE"

# Detect changed files for auto-skip detection
# Detect changed files for auto-skip detection.
# For pull_request events, GitHub Actions checks out a synthetic merge
# commit where HEAD^1 is the base (main) and HEAD^2 is the PR head.
# Diffing HEAD^1 against HEAD (the merge result) gives exactly what this
# PR would introduce on top of the current base; this avoids two failure
# modes of the previous logic:
# - HEAD^2..HEAD returned base-side changes since the PR branched,
# so non-doc PRs were misclassified as docs-only.
# - HEAD^1..HEAD^2 would, if main has advanced since the PR branched,
# surface those base-only changes as PR-side deletions and
# misclassify a docs-only PR as needing a build.
if [[ "$EVENT_NAME" == "pull_request" ]]; then
CHANGED_FILES=$(git diff --name-only HEAD^2 HEAD 2>/dev/null || git diff --name-only HEAD^ HEAD 2>/dev/null || echo "")
CHANGED_FILES=$(git diff --name-only HEAD^1 HEAD 2>/dev/null || git diff --name-only HEAD^ HEAD 2>/dev/null || echo "")
else
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD 2>/dev/null || echo "")
Comment on lines +75 to 89
fi
Expand Down
Loading