Description

Ensure the repository's default branch has an active ruleset applied to it, establishing a baseline of protection rather than leaving the branch completely unprotected.

Rationale

Without any active ruleset, the default branch has no restrictions on direct pushes, deletions, force pushes, or unreviewed merges. A baseline ruleset is the foundation required before any of the more specific protections, such as required reviews or status checks, can be enforced.

Impact

  • Establishes a minimum baseline of protection for the repository's most important branch

  • Provides the foundation required to enforce reviews, status checks, and other controls

  • Reduces the risk of unrestricted direct pushes, deletions, or force pushes to production code

  • Supports compliance with secure software development frameworks

Default Value

By default, a newly created repository's default branch has no ruleset applied to it.

Pre-Requisites

  • Admin access to the repository

Test Plan

  1. Sign in to GitHub at https://github.com.

  2. Select the relevant repository.

  3. Click Settings.

  4. In the "Code, planning, and automation" section of the sidebar, click Rulesets.

  5. Verify that an active ruleset exists whose target branches include the default branch.

  6. If no active ruleset covers the default branch, follow the implementation steps.

Implementation Steps

  1. Sign in to GitHub at https://github.com.

  2. Select the relevant repository.

  3. Click Settings.

  4. In the "Code, planning, and automation" section of the sidebar, click Rulesets.

  5. Click New ruleset, then New branch ruleset.

  6. Under Ruleset Name, enter a name, and set Enforcement status to Active.

  7. Under Target branches, click Add target, then select Include default branch.

  8. Under Rules, select the protections appropriate to your organization's policy, such as required pull requests, status checks, and restrictions on force pushes and deletions.

  9. Click Create.

Backout Plan

  1. Sign in to GitHub at https://github.com.

  2. Select the relevant repository.

  3. Click Settings.

  4. In the "Code, planning, and automation" section of the sidebar, click Rulesets.

  5. Next to the ruleset targeting the default branch, click the options menu, then click Delete ruleset.

  6. Confirm the deletion.

Reference