branch-protection-bot icon indicating copy to clipboard operation
branch-protection-bot copied to clipboard

[Feature] Wildcard-Branch protection

Open amacado opened this issue 4 years ago • 7 comments

At first let me thank you for this useful action! As I have set this up in our repository I encountered a problem which could lead into a feature request for this action.

We protect our branches based on wildcards, f.e. development/*which matches all branches starting with development/. When your branch-protection-bot action is executed it will create a new branch protection rule (based on the wildcard rules) and not updating our existing wildcard protection. When the action re-enables the 'include administrators' option it will only do it on the newly created branch protection rule.

image

This is not a real problem but enforces us to update all branch protection rules and not just one wildcard when we f.e. want to enforce a new status check.

I have two ideas about this:

  1. Add a configuration option to support specific branch-protection rules (so we can target our wildcard-rules)
  2. Add a configuration option which allows instead of toggling the state of 'include administrators' to remove the newly created branch protection rule

Would love to hear your ideas about it.

amacado avatar Mar 28 '20 15:03 amacado

I'm happy to accept a PR that will automatically create branch protection rules as this is an issue when master branch doesn't have branch protection. The only requests I would have is:

  • Default branch pattern is set to master
  • Handles the case where the branch protection already exists
  • Backwards compatible

What advantage do you see in deleting branch protection over disabling?

benjefferies avatar Mar 28 '20 18:03 benjefferies

What advantage do you see in deleting branch protection over disabling?

How do you disable a branch protection? I don't see an option for that..

amacado avatar Mar 28 '20 18:03 amacado

Sorry I meant disabling 'include administrators'

benjefferies avatar Mar 28 '20 18:03 benjefferies

Hi guys, I wonder if you shouldn't put the default branch as being 'main'. As the new repos are now created with main as a standard on Github. But nothing important really.

crazy-matt avatar Sep 16 '21 11:09 crazy-matt

Or putting in the README as a step example something like:

 - name: "Temporarily disable 'include administrators' default branch protection"
        uses: benjefferies/[email protected]
        if: always()
        with:
          access-token: ${{ secrets.ACCESS_TOKEN }}
          branch: ${{ github.event.repository.default_branch }}

which catch the attention straight away

crazy-matt avatar Sep 16 '21 11:09 crazy-matt

Otherwise, I just loved the idea of this action to handle a situation that Github does not want to handle at the moment probably for security implications. Tested it and it does the job like a charm! Thanks @benjefferies for that

crazy-matt avatar Sep 16 '21 11:09 crazy-matt

Thanks for the suggestions @crazy-matt https://github.com/benjefferies/branch-protection-bot/pull/22

benjefferies avatar Sep 16 '21 12:09 benjefferies