It's hard to get the PR associated with a merge because of rebase or squash.
This action uses the List pull requests associated with a commit API to get the PRs associated with a commit.
Create a workflow (eg: .github/workflows/usage.yml
). See Creating a Workflow file.
name: Usage
on:
push:
pull_request:
workflow_dispatch:
jobs:
run:
name: Run Action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: get-pr
uses: austenstone/list-prs-associated-with-a-commit@main
- run: echo '${{ fromJson(steps.get-pr.outputs.prs)[0].number }}'
- run: echo '${{ fromJson(steps.get-pr.outputs.pr-numbers)[0] }}'
Various inputs are defined in action.yml
:
Name | Description | Default |
---|---|---|
github‑token | Token to use to authorize. | ${{ github.token }} |
owner | Owner of the repository. | N/A |
repo | Name of the repository. | N/A |
sha | The commit SHA. | ${{ github.event.after |
Name | Description |
---|---|
prs | The PRs associated with the commit as JSON. |
pr-numbers | The PR numbers associated with the commit as JSON. |
To get more help on the Actions see documentation.