Skip to content

Commit

Permalink
Generate short hash for e2e trigger directly with git (#123)
Browse files Browse the repository at this point in the history
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

The generated hashes from `short-sha` did not always match the Docker
image. This is because Github Actions creates a new merge commit for
pull requests: https://github.com/orgs/community/discussions/26325

### How

Find the actual source commit and create a hash from that.
  • Loading branch information
danieljharvey committed Nov 1, 2023
1 parent ed67719 commit a0a3248
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

# pull requests create a new merge commit so we have to work our way back
# to the actual commit so it matches the Docker image
- name: Generate short SHA
uses: benjlevesque/short-sha@v2.2
id: short-sha
with:
length: 9
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
GITHUB_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha)
fi
echo "hash=$(git rev-parse --short=9 "$GITHUB_SHA")" >> $GITHUB_OUTPUT
id: short-git-hash

- name: Wait for Docker image to be created
uses: lewagon/wait-on-check-action@v1.3.1
Expand All @@ -28,7 +34,7 @@ jobs:
uses: aurelien-baudet/workflow-dispatch@v2
id: workflow_dispatch
with:
inputs: '{ "connector": "${{ steps.short-sha.outputs.sha }}" }'
inputs: '{ "connector": "${{ steps.short-git-hash.outputs.hash }}" }'
repo: hasura/v3-e2e-testing
ref: main
token: ${{ secrets.E2E_WORKFLOW_PAT }}
Expand Down

0 comments on commit a0a3248

Please sign in to comment.