Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
git-pull-request

GitHub Action

Find Current Pull Request

v1.0.1

Find Current Pull Request

git-pull-request

Find Current Pull Request

Find a PR associated with the current commit

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Find Current Pull Request

uses: jwalton/[email protected]

Learn more about this action in jwalton/gh-find-current-pr

Choose a version

gh-find-current-pr

This action tries to figure out the current PR.

If the event is a pull_request, it's very easy to get the current PR number from the context via ${{ github.event.number }}, but unfortunately this information does not seem to be readily available for a push event. This action sends a request to GitHub to find the PR associated with the current SHA, and returns it in the pr output. pr will be an empty string if there is no PR.

Usage

    steps:
      - uses: actions/checkout@v1
      # Find the PR associated with this push, if there is one.
      - uses: jwalton/gh-find-current-pr@v1
        id: findPr
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
      # This will echo "Your PR is 7", or be skipped if there is no current PR.
      - run: echo "Your PR is ${PR}"
        if: success() && steps.findPr.outputs.pr
        env:
          PR: ${{ steps.findPr.outputs.pr }}