gitgithubgithub-codereviews

Don't require accepts for commits to develop branch with certain name pattern


In our GitHub repository we've recently enabled Require pull request reviews before merging rule for develop branch.

Also, we have a little bash script that creates a new version that does the following:

We run this script in develop branch, and it's commits have certain name pattern: New version: ${new-version}.

Problem

Because of "Require pull request reviews before merging" rule, "new version"-commits are now being rejected since they have no accepts, which seems to be totally reasonable.

Question

Is there a way to not enforce "Require pull request reviews before merging" rule for commits with certain name pattern?


Solution

  • No, there isn't a way to do that, since anyone could create a commit with that pattern and bypass the restriction, in which case you might as well not have the restriction at all.

    If you want to allow these commits, you can use a bot to automatically approve and merge them (assuming it has write access), or you could try writing a GitHub Action that runs on pull requests and automatically merges them if they are of a certain type (although it's possible that might not work, depending on the protected branch settings you have).