Skip to content

Finding SHA or ref of branch for [push] event after a pull-request #26459

Answered by ghutchis
ghutchis asked this question in Actions
Discussion options

You must be logged in to vote

I think this is a fairly common use case, judging from some of the searching I did. I think push events made to a pull request should be able to fetch their branch point.

This doesn’t work robustly, but is close enough for now:

# I didn't use ${{ github.repository }} because that points to the fork
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/openchemistry/avogadrolibs

git fetch origin master:master
export MASTER_SHA=cat .git/refs/heads/master
git diff ${MASTER_SHA} --name-only

whatever else you want to do

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@kirkath
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants