Automatically add a Reviewed-by trailer to Pull Requests
MIT License
This GitHub Action will automatically append a Reviewed-by:
trailer to the body of a pull_request
when a review is completed. This can then be used with git shortlog -ns --group=trailer:reviewed-by
to see who is reviewing the most pull requests.
To use this action, you must always Squash and Merge
pull requests, using the body of the PR as the commit message for the squashed commit.
Create the following file at .github/workflows/pull_request_review-trailer.yml
:
name: PR Review
on: pull_request_review
jobs:
review:
name: Reviewed-by Trailer
runs-on: ubuntu-latest
steps:
- name: Debug
uses: mheap/reviewed-by-trailer-action@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
states: approved,changed_requested
You will need to add a GitHub API token as a secret named PAT
to use this action. The GITHUB_TOKEN
available in the environment does not have enough permissions to fetch the data we need to populate the user name and email address in the trailer.
This action accepts a comma-separated states
input to control which events trigger Reviewed-by
to be added. The available states are:
approved
changes_requested
commented
The default value for this field is approved
, which means that only approving reviews will be added. The example above enables the action for both approved
and changes_requested