Skip to content

Getting the hash of the last commit when merging #25989

Discussion options

You must be logged in to vote

Hi @mdneuzerling,

Glad to see you in Github Community Forum!

Since the hash exists in the github.event.commits array, you can use below sample code to get the second-last id, not ideal but it works.

      - name: get the sha
        run: |
          echo "$GITHUB_CONTEXT"| jq '.event.commits[].id' | tail -2 | head -1 |sed 's/\"//g'
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}

Please refer to my workflow for your reference.

GitHub

weide-zhou/ticket13

Contribute to weide-zhou/ticket13 development by creating an account on GitHub.

Thanks.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants