Skip to content

Add protected branches configuration for main branch#642

Open
dave2wave wants to merge 2 commits intomainfrom
branch-protection
Open

Add protected branches configuration for main branch#642
dave2wave wants to merge 2 commits intomainfrom
branch-protection

Conversation

@dave2wave
Copy link
Copy Markdown
Member

As @potiuk suggested in #638

Signed-off-by: Dave Fisher <dave2wave@comcast.net>
@dave2wave dave2wave marked this pull request as ready for review March 31, 2026 15:20
@dave2wave dave2wave requested review from dfoulks1, potiuk and raboof March 31, 2026 15:21
Copy link
Copy Markdown
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love others to agree.

Copy link
Copy Markdown
Member

@raboof raboof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but would be good to have an infra confirmation as well

.asf.yaml Outdated
features:
issues: true
protected_branches:
main: {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to specify some options here?
https://github.com/apache/infrastructure-asfyaml?tab=readme-ov-file#branch-protection

for example, for another apache project, we use

  protected_branches:
    main:
      required_pull_request_reviews:
        required_approving_review_count: 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not explicitly specified, these values will be used by default:

required_signatures: false
required_linear_history: false
required_conversation_resolution: false
required_pull_request_reviews:
  dismiss_stale_reviews: false
  require_last_push_approval: false
  require_code_owner_reviews: false
  required_approving_review_count: 0
required_status_checks:
  strict: false
  contexts: ~
  checks: ~

i think we need to add some options, otherwise default doesnt enforce anything

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default will disallow pushing to the main branch, I think, right? That would be a good start... though come think of it I wonder if that wouldn't also prevent the GHA automations that update approved_actions.yml and .github/workflows/dummy.yml from pushing to the main branch?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please commit changes to the branch. If there are problems after the merge we can revert and fix.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, each branch protection rule disables force pushes to the matching branches and prevents the matching branches from being deleted. You can optionally disable these restrictions and enable additional branch protection settings.

https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches#about-branch-protection-rules

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can merge and give it a try too

.asf.yaml Outdated
features:
issues: true
protected_branches:
main: {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not explicitly specified, these values will be used by default:

required_signatures: false
required_linear_history: false
required_conversation_resolution: false
required_pull_request_reviews:
  dismiss_stale_reviews: false
  require_last_push_approval: false
  require_code_owner_reviews: false
  required_approving_review_count: 0
required_status_checks:
  strict: false
  contexts: ~
  checks: ~

i think we need to add some options, otherwise default doesnt enforce anything

@potiuk
Copy link
Copy Markdown
Member

potiuk commented Apr 1, 2026

i think we need to add some options, otherwise default doesnt enforce anything

Agree -> required_approving_review_count = 1 likely.

@dave2wave
Copy link
Copy Markdown
Member Author

Pulsar has some interesting notes about CI workflows these go with their .asf.yaml

Add required status checks and pull request review settings for the main branch.

Signed-off-by: Dave Fisher <dave2wave@comcast.net>
Copy link
Copy Markdown
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we want to set require_code_owner_reviews, everything else looks good to me

Comment on lines +25 to +27
required_status_checks:
# strict means "Require branches to be up to date before merging".
strict: false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already the default value, but doesnt hurt to be explicit

strict: false
required_pull_request_reviews:
dismiss_stale_reviews: false
require_code_owner_reviews: true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we set this? default is false, who are the code owners ?

# strict means "Require branches to be up to date before merging".
strict: false
required_pull_request_reviews:
dismiss_stale_reviews: false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, dismiss_stale_reviews: false is the default but doesnt hurt to be explicit

required_pull_request_reviews:
dismiss_stale_reviews: false
require_code_owner_reviews: true
required_approving_review_count: 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants