GitHub PR mergeability

No rule protection on pull request, PR that failed in CI is still mergable
Problem

As you can see in the above screenshot, my last commit in this PR deliberately fails the CI flow in Drone and we can see the "All checks have failed" warning. But this PR is still mergable (even by a non-admin user).

Most of the time, we want to block pull requests that don't pass status checks from merging into master branch. GitHub provides a great feature called Branch protection rule to achieve this goal (doc).

Solution

Create a Branch Protection Rule
This function is located in repository Settings > Code and automation > Branches > Add rule

Let's create the rule as below:

Notice that the Branch name pattern field, the value shouldn't contain any white space. Otherwise, you'll get a invalid rule error message.

Now we have a rule to block PR with failing status.

Administrator still can merge PR even the checks have failed

By checking the Include administrators option, the restrictions will be applied to administrators too.