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
8 changes: 5 additions & 3 deletions .github/workflows/visual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
# PR checkouts are merge commits; HEAD^1 is the main commit they're compared against.
# PR checkouts are merge commits; HEAD^1 leads back to the main commit they're compared against.
fetch-depth: 2
persist-credentials: false

Expand Down Expand Up @@ -85,7 +85,9 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
sha=$(git rev-parse HEAD^1)
# Stacked PRs merge onto their parents' merge commits, so compare against the main commit
# at the bottom of the stack rather than HEAD^1 itself.
sha=$(gh api "repos/$GITHUB_REPOSITORY/compare/main...$(git rev-parse HEAD^1)" --jq .merge_base_commit.sha)
latest() {
gh run list -R "$GITHUB_REPOSITORY" --workflow visual.yml --branch main --event push \
--commit "$sha" --limit 1 --json databaseId,status,conclusion --jq '.[0] // empty'
Expand All @@ -99,7 +101,7 @@ jobs:
fi
if [ "$(jq -r '.conclusion // empty' <<< "$run")" = success ] &&
gh run download "$(jq -r .databaseId <<< "$run")" -R "$GITHUB_REPOSITORY" -n visual-screenshots -D out/baseline; then
echo "Using screenshots from run $(jq -r .databaseId <<< "$run")"
echo "Using screenshots from main at $sha (run $(jq -r .databaseId <<< "$run"))"
else
echo "::notice::No screenshots published for main at $sha; cases are reported as new"
fi
Expand Down
Loading