This Github Actions helps find a Pull Request in the context of a push
or pull_request
Github Action.
For a real-world action, this repo runs itself via add-pr-comment.yml to comment on every PR.
name: Add PR Comment
# NOTE: We support both `push` and `pull_request`, but see the input documentation as they are different.
on: [push, pull_request]
jobs:
add-pr-comment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Find Pull Request
id: find-pr
uses: sharesight/find-github-pull-request@1.3.0
with:
# These are all default values.
token: ${{ secrets.GITHUB_TOKEN }}
commitSha: ${{ github.sha }}
allowClosed: false
failIfNotFound: false
- name: Debug
run: |
echo number: ${{ steps.find-pr.outputs.number }}
echo title: ${{ steps.find-pr.outputs.title }}
echo body: ${{ steps.find-pr.outputs.body }}
echo url: ${{ steps.find-pr.outputs.url }}
echo url: ${{ steps.find-pr.outputs.base-ref }}
echo url: ${{ steps.find-pr.outputs.base-sha }}
All inputs are optional and only used for an on: pull
event!
If doing on: pull_request
, we get this data directly from the payload and inputs are generally ignored…
Name | Description | Example / Default Value |
---|---|---|
token | Github Token used to fetch pull requests. | ghp_Abc123 |
commitSha | For on: pull , the sha to look for, defaults to current. |
abcdef123 |
allowClosed | For on: pull , allows returning a closed PR. |
false |
failIfNotFound | For on: pull , fail if not found at that sha. |
false |
NOTE: title
and body
are sanitized to remove quotes and backticks to avoid shell interpolation.
Name | Description | Type or Example Value |
---|---|---|
number | The found PR number | '12345' |
title | The found PR title | string |
body | The found PR body | string |
url | The found PR url | https://github.com/sharesight/find-github-pull-request/pull/1 |
base-ref | The base ref | 'main' |
base-sha | The base sha | 'dc45d5195b1f2510b7e83d7cb6a836ba09b2358d' |
yarn install
code .
yarn jest:tdd
- Decide on a semver, eg.
1.2.3
. - Bump this version in
package.json
file—just for the sake of it. - Bump this version in
README.md
file. - Update the
CHANGELOG.md
file with relevant release information. - Ensure that
yarn build
already has been ran and adist/index.js
committed; commit if not. - Version bumps should go via a PR and be merged into master before releasing.
Manually build a New Release: here
- Enter your tag based on the semver.
- Your tag should be prepended with a
v
, eg.v1.2.3
. - Do not use
@latest
tag.
- Your tag should be prepended with a
⚠️ Point the release to the correct commit (not main)! This should be the PR Merge commit.- Enter a title naming the release (eg.
v1.2.3: Brief description of changes
) - Enter a fuller description—link to commits, PRs, etc.
- Release!