We host all our repos on GitHub and recently I was tasked to implement GitFlow. The problem is with the branch protection strategy we have in place. We have made master, develop and release/* branch protected and all PRs to these branches require at least 1 review before it can get merged.
When someone executes:
git flow release finish RELEASE
it successfully merges the RELEASE branch to master and develop, but the problem comes when the same changes need to be pushed to remote (git push). Due to the branch protection in place, GitHub rejects the change with a message like below, unless the person doing the git push is an owner.
ā xyz git:(develop) git push
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 238 bytes | 238.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0)
remote: error: GH006: Protected branch update failed for refs/heads/develop.
remote: error: At least 1 approving review is required by reviewers with write access.
To github.com:company1/xyz.git
! [remote rejected] develop -> develop (protected branch hook declined)
error: failed to push some refs to 'git@github.com:company1/xyz.git'
Here is our standard repo permission:
We have thought of two solutions none of which seem ideal to me: 1. Allow force push to all the protected branches. 2. Use a Jenkins pipeline to finish the release. Use an owner account to run the git flow release finish RELEASE.
We have many microservices and theoretically, anybody can do a release, thus restricting who can do the release and then giving them the owner or maintainer access won't scale. How have you solved this? What is the best way forward?
P.S: I already looked at all the related questions posted here and on other forums and have not found any clear solution.