Auto-merge in GitHub

GitHub supports auto-merging of pull requests (PRs) when GitHub Actions succeed. This is a bit of an overlooked feature (I see almost no one using it) and it’s also poorly documented. So, here is a little tutorial. For the repository that you want to enable auto-merge:

Go to “Settings” and enable “Allow auto-merge”:

Go to “Settings → Branches” and enable branch protection for your main branch:

In the branch protection rule for main, set at least one required status check:

Here, “build-and-deploy” is the name of the job that you defined in your .yml file in .github/workflows/.

Use auto-merge

Now, when you create a PR on a repository for which you have sufficient rights, you can click on “auto-merge”:


Note: It is very important to specify a job! Otherwise, the “auto-merge” button will simply not appear.

6 Likes

Edit: nvm I get it.