David Oliver
David Oliver

Reputation: 71

GitHub - how to implement multi-tier branch protection rules?

We have a repo that already has a standard branch protection rule of requiring at least 1 approval. I'm curious to know if there's any way to setup a multi-tier rule for this branch. Specifically, what I'm trying to enable is: if certain files are modified in the pull request, I would want at least 2 approvals before merge. It doesn't seem like the UI makes this possible, but I'd be interested to know if - perhaps through Actions - there is a clever way to accomplish this?

Upvotes: 2

Views: 606

Answers (1)

I haven't seen how this can be done in the UI either. One way you could achieve this though is to create a branch protection rule that requires a status check to pass, and make a Github Action that runs a script checking on the number of approvals the request currently has using the Github context object. Then you can get as granular as you like in the script. Something similar to how gautamkrishnar manages limiting pull requests to particular branches here (archived link).

Upvotes: 1

Related Questions