gh-find-current-pr icon indicating copy to clipboard operation
gh-find-current-pr copied to clipboard

Find pr during workflow triggered by push after rebase merge

Open wickkidd opened this issue 3 years ago • 0 comments

This is what I found to work. It's not fool-proof as the same commit message could occur more than once and have been in more than one pr.

- name: Find PR
  id: find_pr
   env:
     GH_TOKEN: ${{ github.token }}
   run: |
     prs=$(gh pr list --search "${{ github.event.head_commit.message }}" --state merged)
     number=$(echo $prs | cut -d ' ' -f 1)
     echo "number=$number" >> $GITHUB_OUTPUT

It would be nice if this action could be made to accommodate this situation. If I get time, I'll take a look at the source to see if there's a sane way to add it.

Fun facts:

  • due to rebase, the commit sha has changed and the new one was never tied to a pr
  • the topic branch may already be deleted (as it is in my case)
  • searching the reflog you'd still end up having to use the message at some point afaict

wickkidd avatar Apr 21 '23 18:04 wickkidd