Skip to content

GitHub Action to dismiss PR reviews when the PR diff changes

License

Notifications You must be signed in to change notification settings

petalmd/waitaminute

Repository files navigation

Wait a minute...

waitaminute status

A GitHub Action that dismisses reviews from PRs when the PR diff changes.

But... why?

Doesn't GitHub already support this?

It... kinda does. However, from experience, the GitHub feature sometimes clears reviews when you merge the base branch in the PR branch, or when you rebase, even if the PR diff itself doesn't change. If you experience this and it bothers you, this action is for you.

Using this action

  1. In the Actions tab of your repository, choose New workflow, then click on setup a workflow yourself.
  2. Name your workflow file, for example waitaminute.yml.
  3. Add the workflow definition, like this:
name: Remove approvals when PR diff changes

on:
  pull_request:
    # Here, 'opened' is important because it allows the action to
    # see the initial PR diff and compare it later.
    types: [ opened, edited, synchronize ]
    branches:
      - main

jobs:
  waitaminute:
    runs-on: ubuntu-latest
    steps:
      - uses: petalmd/waitaminute@v2
        with:
          dismiss-message: Review dismissed because the PR has changed.
  1. Click on Start commit to commit your new workflow file, using a PR if necessary.

Action parameters

Name Description Required Default
github-token GitHub personal access token. false ${{ github.token }} (see here)
dismiss-message Message that is displayed when the action dismisses a PR review. false Dismissed by waitaminute because PR diff changed.