Skip to content

Commit

Permalink
Create pr-sha.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsimon committed Oct 19, 2022
1 parent 0c5809c commit 47092a6
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/pr-sha.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: PR sha

on:
pull_request:

permissions: read-all

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Test
env:
CONTEXT: "${{ toJSON(github) }}"
# Exception for pull requests: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
PULL_REQUEST_SHA: "${{ github.event.pull_request.head.sha }}"
run: |
set -euo pipefail
git_sha="$(git log -1 --format='%H')"
github_sha="$GITHUB_SHA"
echo "\"$git_sha\": $git_sha"
echo "\"$github_sha\": $github_sha"
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
github_sha="$PULL_REQUEST_SHA"
echo "pull request, updating github_sha"
echo "\"$github_sha\": $github_sha"
fi
if [[ "$git_sha" != "$github_sha" ]]; then
echo "mismatch git sha \"$git_sha\" != \"$github_sha\""
echo "GitHub context:"
echo "$CONTEXT"
echo
echo "Last 20 commits:"
git log -20
exit 1
fi

0 comments on commit 47092a6

Please sign in to comment.