A nifty little app that automatically merges your PRs when everything is green so you don't have to. 🎳
ISC License
A nifty little app built with Probot that automatically merges your PRs when everything is green so you don't have to.
Code reviews often rely on three aspects: The submitter of the PR, the reviewers, and CI. Writing the code, submitting the PR, and reviewing the PR is a manual process that needs human eyes and brains. The process of CI, however, is something we automate for a reason. It is the place where we do sanity checks and make sure nothing terrible happens to our beautiful software projects. And for a good reason.
Because of this, the following situation can arise: You as a developer developed a new feature and submitted a PR. After some back-and-forth with your team members, the PR gets approved. The only dependency now is the not-so-fast CI, which is still running on your PR. This forces you to revisit your PR later that day to check if CI is green so that you can click the merge button.
This app does exactly that for you. As soon as your PR is approved, and CI passes, the PR gets merged automatically.
The current iteration of the app also auto-merges when CI already is green and a reviewer approves your PR after that. The bottem-line is that the moment everything turns green (Status checks, reviewers and other enforced branch protection rules), this app merges your PR.
This app also adheres to your branch (protection) settings. e.g., if you require at least two reviewers, it won't auto-merge the PR if only one reviewer approves it.
In 3 steps this app can be used in your project.
.github/auto-merge-settings.yml
file. (see template below) This config file supports two options:
merge
/squash
/rebase
, default: merge
, more info
all
/label
, default: label
, apply this auto-merge functionality to all PRs, or only the PR with a auto-merge
labelauto-merge
label to your PR. (not needed if strategy is all
)merge_method: 'squash' # merge/squash/rebase
strategy: 'label' # all/label
Give your app the following permissions:
Category | Permission | Why |
---|---|---|
Repository contents | Read & Write | to perform merges |
Repository metadata | Read | to read config file |
Pull Requests | Read | to read labels |
Commit Statuses | Read | to read status checks |
git clone [email protected]:SvanBoxel/auto-merge.git
Copy .env.example
to .env
and set the right environment variables as here
Now, install app dependencies and run it:
# Install dependencies
npm install
# Run the bot
npm start
If you have suggestions for how auto-merge could be improved, or want to report a bug, open an issue! We'd love all and any contributions.
For more, check out the Contributing Guide.
ISC © 2018 Sebass van Boxel [email protected]