Skip to content

fix: verify-checkout uses wrong sha to validate for pull_requests #941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 30, 2022
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
13 changes: 10 additions & 3 deletions .github/actions/verify-checkout/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ runs:
shell: bash
env:
CONTEXT: "${{ toJSON(github) }}"
PULL_REQUEST_SHA: "${{ github.event.pull_request.head.sha }}"
run: |
set -euo pipefail

git_sha=$(git log -1 --format='%H')
if [[ "$git_sha" != "$GITHUB_SHA" ]]; then
echo "mismatch git sha \"$git_sha\" != \"$GITHUB_SHA\""
git_sha="$(git log -1 --format='%H')"
github_sha="$GITHUB_SHA"

if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
github_sha="$PULL_REQUEST_SHA"
fi

if [[ "$git_sha" != "$github_sha" ]]; then
echo "mismatch git sha \"$git_sha\" != \"$github_sha\""
echo "GitHub context:"
echo "$CONTEXT"
echo
Expand Down