🐛 Fix GitHub Actions PR commit SHA detection #182
Merged
+303
−11
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.
Summary
pull_requesteventsGITHUB_EVENT_PATHto extract the actual PR head commit SHA instead of usingGITHUB_SHA(which is a merge commit)Problem
For
pull_requestevents in GitHub Actions,GITHUB_SHApoints to a temporary merge commit, not the actual head commit of the PR. This caused:From GitHub's official docs:
Solution
The CLI now reads the GitHub Actions event payload from
GITHUB_EVENT_PATH(a JSON file containing the full webhook payload) and extractspull_request.head.shafor PR events.pushtomainpull_requesteventVIZZLY_COMMIT_SHAsetChanges
src/utils/ci-env.js:getGitHubEvent()to read and cache event payloadgetCommit()to extract PR head SHAgetPullRequestHeadSha()with same fixgetPullRequestBaseSha()to extract base SHATest plan
GITHUB_SHAfor push events