pr workflow - use merge SHA when available #17
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to:
The changes in #14 result in a failed build when the PR is closed/merged, because the special merge "branch" doesn't exist anymore.
However, I have found that
github.event.pull_request.merge_commit_sha
does exist on closed/merged/reopened PRs. It does not exist on the first opened event though (whereas the merge branch does).I also did some tests showing that when both the merge SHA and the merge branch exist, the content of their checkouts are exactly the same: https://github.com/briantist/gha-junk/runs/4827842600?check_suite_focus=true
This PR sets an output var for the ref we'll be using in the PR checkout. We start with the SHA because that will either be set, or blank. If the SHA is blank, then we fall back to the merge "branch".
I believe this will cover all bases.