How to Automatically Merge Pull Requests on GitHub

0 Comments
Editor Ratings:
User Ratings:
[Total: 0 Average: 0]




This tutorial explains how to automatically merge pull requests on GitHub. Mergify is a free online app that gets integrated in your selected GitHub repositories and watches for all incoming pull requests. It lets you define some rules to merge a pull request automatically on GitHub. You can create the rules by yourself and then put the process of merging branches in auto pilot. You can use Mergify on a specific GitHub repository or on all your repositories. However, to make it work, you will have to create a configuration file. And the configuration file is nothing but a set of rules that you can easily create.

Sometimes it becomes very irritating to merge each pull request on GitHub manually. So, wouldn’t it be nice to have tool that will help you manage all the pull request automatically? Luckily, to automatically merge pull requests, you can use Mergify. All you have to do is learn how to create rules to pass a merge request. A simple rule that you can make is “Merge Pull Request when Specified number of reviewers approve it”. You can create rules like these and sit back and let Mergify do the rest.

How to Automatically Merge Pull Requests on GitHub

How to Automatically Merge Pull Requests on GitHub?

Mergify is a powerful tool that you can use to automate pull request on your projects. However, it is free for open source projects only. For teams and developer use, you will have to upgrade to its premium plan. After signing up, you will have to connect your GitHub account and you can even sign up for this tool via your GitHub account as well.

Follow these steps to learn how to use Mergify.

Step 1: After sign up for the Mergify from its homepage, simply add the repositories on which you want to install it. You can either install all repositories or you can select any one.

Mergify add repositories

Step 2: Now, you will have to create a configuration file in the root of the selected directory. So, create a “.mergify.yml” file and add the rules in it. By default, it will follow a default template. But it’s good to define your own rules. To create rules, you can see the documentation here. Below is the example of a rule that will merge a pull request automatically when it is approved by one user.

rules:
default:
protection:
required_status_checks:
contexts:
- continuous-integration/travis-ci
required_pull_request_reviews:
required_approving_review_count: 1

configure merging rules

Step 3: Now, when you have configured Mergify, it’s time to let it run on its own. It will keep watching all the incoming pull requests. When a pull request comes, it will go through Mergify first. And if the rules that you have created pass the request, it will merge it automatically. You can see the status of the merging from the pull requests section too. For example, in my case, the pull request won’t merge until approved by one reviewer.

Mergify in action

In this way, you can use this free tool to automatically merge pull request on GitHub. If you more often use GitHub then you can use this whole new way of dealing with the pull requests. And Mergify makes it very easy to do that. You will have to first understand it how to create different rules to merge pull requests.

Also see:

Final thoughts

Mergify is really a nice tool to automatically merge pull request on GitHub. And not just automatically, but if you still want to merge PRs manually, then you can do that. Just sign for Mergify, install it on the target repository and specify the merging rules. After that, let it handle the PRs automatically.

Editor Ratings:
User Ratings:
[Total: 0 Average: 0]
Free/Paid: Free

Leave A Reply

 

Get 100 GB FREE

Provide details to get this offer