From a0a32489caa04ebae49f200862d1eddbea5eb96f Mon Sep 17 00:00:00 2001 From: Daniel Harvey Date: Wed, 1 Nov 2023 11:21:29 +0000 Subject: [PATCH] Generate short hash for e2e trigger directly with git (#123) ### 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. --- .github/workflows/e2e-test.yaml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e-test.yaml b/.github/workflows/e2e-test.yaml index a0c0c1d1e..ad3acd95d 100644 --- a/.github/workflows/e2e-test.yaml +++ b/.github/workflows/e2e-test.yaml @@ -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 @@ -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 }}