Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get last commit sha from pull_request in push action?

In the context of github-actions, how do I get sha of the last commit in the PR before it was merged?

I want to get this sha in the context of push workflow, i.e.

on:
  push:
    branches:
      - master

If push was not triggered by a PR merge, then I need a way to ignore the action.

like image 259
Gajus Avatar asked May 17 '26 19:05

Gajus


1 Answers

You can try using {{ github.event.pull_request.head.sha }} and comparing it to ${{ github.sha }}

like image 150
Nicholas Bergesen Avatar answered May 20 '26 17:05

Nicholas Bergesen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!