Skip to content

Get the sha of the target branch on worklow run #25367

Answered by akoskm
akoskm asked this question in Actions
Discussion options

You must be logged in to vote

You’re right, I just made the following test:

while in context I have:

"event": {
    "after": "85f578ec7e036f138b09c93ad1f252da4b7d10a3",
    "base_ref": null,
    "before": "4679d7e9916dcc9a1605d4b12a8b0a86f9c40f51",

This is clearly what I need, now I just have to find a way to get to context.event.before/after - I think it’s just ${{ github.event.before }} - and send those SHA to my script.

Is there any difference these:

git diff --name-only ${{ github.event.before }} $GITHUB_SHA
git diff --name-only ${{ github.event.before }} HEAD
git diff --name-only ${{ github.event.before }} ${{ github.event.after }}

If I understand correctly all 3 would point to the latest…

Replies: 17 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
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
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
4 participants