Get last merged PR’s branch name or PR number

Is it possible to get branch name or PR number of the last merged branch to main, if yes how can we achieve this in github workflow file.

Use-case:
I am uploading an artifact when a PR is merged to main using a workflow, so while downloading i need to give the workflow and branch name to download it in other PRs.

I tried to find some github actions for this but could not find any

  • 2

    You’re likely going to have to go thru the Github REST API for that information. To git a commit is just a commit, it has no internal concept of a Github pull request.

    – 

Leave a Comment