Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a user exception to "Require pull request reviews before merging" option in git protected branch?

I am trying to use lerna publish to manage package publishing in my team. So what lerna does at the end of every publish is, it bumps the version in the package.json file and commits those changes in the branch that did the publish.

However in master I need "Require pull request reviews before merging" to be active as it is protected branch. Require pull request reviews before merging

My problem is not in publishing as lerna publishes the package. However the circle-ci fails with this error:

remote: error: GH006: Protected branch update failed for refs/heads/publish-test.
remote: error: At least 1 approving review is required by reviewers with write access.
To github.com:username/repo.git
 ! [remote rejected] publish-test -> publish-test (protected branch hook declined)

I tried enabling "Restrict who can push to matching branches" option to allow a user to commit in master, (we are using a bot user for devops commits). Restrict who can push to matching branches

Is there a way to add a user exception to the option "Require pull request reviews before merging" or do a pre-merge hook(so I can publish before the merge in ci)?

like image 866
Pravin Avatar asked Sep 07 '25 10:09

Pravin


1 Answers

Update: GitHub Enterprise now has the ability to create custom roles in which you can assign the permission to bypass branch policy.

The only way to exempt users is to make them repo admins and allow admins to bypass the policy.

Or use a GitHub actions workflow that uses the PAT if an admin to push to the target branch if the changes were pushed by allow-listed users. That opens up some interesting security issues though.

like image 101
jessehouwing Avatar answered Sep 10 '25 01:09

jessehouwing