I have a team working in few GitHub repositories. Each repository has responsible person (maintainer) who performs final review of pull requests and merging it to master if it's OK. All other members are developers and reviewers for this repository (but may have maintainer role in another repo). The workflow is:
- Member1 submits PR
- Member2 reviews PR
- Maintainer reviews and merges PR
To require PR review I enabled "branch protection rules" to master and checked "Require pull request reviews before merging". But when team members approves PR, it doesn't become "green" and maintainer can't merge it, to make PR approval "green" I changed team members access to "write". But now each member can merge pull requests without maintainer involvement:
- Member1 submits PR
- Member2 reviews PR
- Member1 o Member2 merges PR (if they have write access)
Also, write access gives an ability to close tickets and pull requests. Of course, we may have verbose agreement that somebody is a maintainer and only this person can merge PRs in some particular repo, but in this case I don't see how GitHub helps with this "branch protection rule".
Is it possible to automate this workflow using GitHub configuration? I want to give only "read" permissions in each repository to developers and reviewers and "maintain" role to maintainer.
I see some possible workarounds, but it's needed to implement it manually:
- Using GitHub actions: trigger GitHub action on PR approve event, check if approver is a team member and has "read" access, approve PR from action.
- Use simple hosted server with a bot user: add bot user to a repo with write permission, listen for webhooks on a server, and approve PR via API using bot token on approve webhook from team member.
Maybe I missed something and I can do it without writing code but just using GitHub? It seems to be very common practice, I don't see why it's not implemented on GitHub side.
