Michal Karbownik
Michal Karbownik

Reputation: 1437

Template for pull request reviews

GitHub allows for creating PR templates. Is it possible to do the same, but for pull request reviews?

An example of such would be adding a review checklist, like the following:

- [] Have all the GitHub checks passed?
- [] Is there any redundant code?
- [] Could any optimization be applied?

Upvotes: 5

Views: 3095

Answers (1)

Christian
Christian

Reputation: 5541

In GitHub, there are no templates for pull request reviews. A GitHub action allows you to do something when a draft PR is changed to the ready_for_review state:

on:
  pull_request_target:
    types:
      - ready_for_review

For example, you can post a comment that contains checkboxes in this step, e.g. by usíng marocchino/sticky-pull-request-comment. I have created a comment in this PR and I am excited about how well this works.

Full GitHub action example:

name: "Pull request checklist"
on:
  pull_request_target:
    types:
      - ready_for_review
jobs:
  pull_request_info:
    runs-on: ubuntu-latest
    steps:
      - name: Extract branch name
        shell: bash
        run: echo "##[set-output name=branch;]$(echo ${GITHUB_HEAD_REF})"
        id: extract_branch

      - name: Checkout repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Show checklist
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          header: show_checklist
          message: |
            - [ ] Checklist item 1
            - [ ] Checklist item 2

For more options, check out the:

Upvotes: 2

Related Questions