28

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)?

jthill
  • 55,082
  • 5
  • 77
  • 137
Pravin
  • 1,671
  • 5
  • 23
  • 36

2 Answers2

2

Update

GetHub enterprise now has the ability to create custom roles in which you can assign the permission to bypass branch policy.


The only way to excempt 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.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
-1

No there currently is no option for that but you could raise a feature request here. There probably is no way to work around the branch protection, which is pretty much the point of it.

On your second question: As far as I know, there is no specific "pre-merge" hook, here is the list of all workflow triggers. You could work around this triggering at push for the branch you are merging to or could trigger on creating a release or maybe one of the mentioned pull-request hooks can enable your scenario.

creyD
  • 1,972
  • 3
  • 26
  • 55