1

I am aware of similar questions (How to protect "master" branch in GitHub? and How can we enforce mandatory reviews in GitHub but still allow Maven release builds from CI?) and of GitHub's "protected branches" feature. Sadly, so far, I have been unable to come up with a solution that fulfills all our requirements:

  • only administrators and automated process accounts (like Maven release on Jenkins) can push directly to master
  • everybody else must open a pull request (which requires an approval)
  • everybody can merge approved pull requests

We are a small organization on a GitHub "Team" plan, and we're happy to switch plans, if necessary. However, I'd like first to make sure that whatever other plan we choose would actually support all these requirements.

raner
  • 1,175
  • 1
  • 11
  • 21
  • The company I work for is switching from bitbucket to github and we're hitting the same issue. Apparently we can't add exceptions (e.g.: service user) to a protected branch (e.g.: `master`). Another limitations we found are adding exceptions with wildcards (e.g.: `Sprint-*`) or add more that one reviewer per PR and default reviewers. I'd recommend you to research and eval other tools in the market and see if it fits better your requirements. – joao cenoura Jan 22 '18 at 20:33

1 Answers1

0

go to settings tab click on Branches --> select Branch Protection Rules and here click Add Rules button, Branch name patterns = master

then tick below checkboxes 1)Require pull request review before merging 2)Require review from CODEOWNER file.

Add your your automated process accounts to Admin roles of git.

Note:-Add CODEOWNER file in your git top folder and inside it maintain Lead developers who can approve name like this * @apple @orange

You can read more on codeowner in below link https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

We haven't ticked include administrator option, Admin role account can do merge without review.