A GitHub action to automatically dismiss stale approvals on pull requests.
Unlike the built in GitHub protection, this action will compare the git range-diff of the new version against the previous version, and only dismiss approvals if the diff has changed.
- Add the below workflow to your repository's
.github/workflowsdirectory. - Ensure that this GitHub Action is required for pull requests, which will ensure that PRs cannot be merged until the action has run successfully.

You can make the check required with either:
See the example repository for a complete example.
name: Dismiss stale pull request approvals
on:
pull_request:
types: [
opened,
synchronize,
reopened,
]
permissions:
actions: read
contents: read
pull-requests: write
jobs:
dismiss_stale_approvals:
runs-on: ubuntu-latest
steps:
- name: Dismiss stale pull request approvals
uses: withgraphite/dismiss-stale-approvals@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}We (the Graphite team) have limited staffing in this area (mainly due to the need for DSA being a relatively small number of customers), which is why the action is OSS in the first place. It was an issue an enterprise customer asked us for input on while trialing so we created it as the simplest possible solution for the problem as a proof-of-concept. We don't expect it to solve the problem for every single Graphite customer exactly as implemented, which is why some of our other larger customers have forked the repo for their desired use.
Feel free to fork to fit your exact use case, and we'd love back-contributions if you feel they'd be useful for others. Keep in mind that a change may work best as an optional configuration for the action, depending on exactly what the change is, of course.
If we don't respond on GitHub immediately to an issue or PR, feel free to bring it to our attention in our Community Slack server.
This repository is public source, but protected by copyright per GitHub defaults (see here). Graphite customers have express permission to use this action or a fork in their repositories by default.