Skip to content

How to get latest commit from a PR merge? #25771

Answered by BrightRan
Andre601 asked this question in Actions
Discussion options

You must be logged in to vote

@Andre601,

To get the title of the PR, you can use the expression “github.event.pull_request.title” to get it from the github context, when the workflow is running on the events for pull request.
For example:

echo "The title of PR is: ${{ github.event.pull_request.title }}"

To get the latest commit on the PR, you can do as the steps below:

  • Use the “List commits on a pull request” API to list all the commits on current PR, and save the response as JSON.
  • Use jq filter to get the latest commit from the commits list (the list is a JSON array). Generally, the latest commit is the last element of the array, so you need to get the index (length - 1) of this element.
    The following is a simple d…

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants