Skip to content

How to build a Docker image using github action for the last commit on a pull request #25382

Answered by Yanjingzhu
uditgaurav asked this question in Actions
Discussion options

You must be logged in to vote

The GITHUB_SHA of issue_comment event is the Last commit on default branch. So it could not get the last commit on pull_request.
As a work around , please follow next steps to get the last commit in PR

  1. You could get the PR number from the payload of issue comment event : github.event.issue.number .
  2. Use the PR number to get its commits through this API . You could use octokit/request-action to send request to GitHub API. This action will output the response body to an output variable data.
  3. Use jq to get the commit id from the response data. Then set the value to an output variable
  4. When execute checkout action, you could add ref parameter with the commit id as value.
    There is my sample wor…

Replies: 2 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
2 participants