This guide explains how to configure Branch Protection Rules for the main branch.
- Repository owner or admin access
- Completed Phase 1-3 implementation (CI workflow + Platform tests + Release workflow)
- Go to GitHub repository: https://github.com/nahisaho/MUSUBI
- Click Settings (top right)
- In left sidebar, click Branches
- Click Add branch protection rule
- Branch name pattern:
main
- Require a pull request before merging
- Required approvals: 0 (small team)
- Dismiss stale pull request approvals when new commits are pushed
- Require review from Code Owners (if CODEOWNERS file exists)
- Require status checks to pass before merging
- Require branches to be up to date before merging
Search and add the following 11 required checks:
lint / ESLint & Prettiertest / Jest Testsbuild / Build Verificationaudit / Security Auditplatform-tests / Platform Tests (claude-code)platform-tests / Platform Tests (github-copilot)platform-tests / Platform Tests (cursor)platform-tests / Platform Tests (gemini-cli)platform-tests / Platform Tests (windsurf)platform-tests / Platform Tests (codex)platform-tests / Platform Tests (qwen-code)
Note: These status check names appear after running the CI workflow at least once. If they don't appear in the search, merge a PR first to trigger the workflow.
- Require conversation resolution before merging
- Require linear history
- Do not allow bypassing the above settings
- Reason: This would prevent even administrators from merging without CI passing. Keep unchecked for emergency hotfixes, but follow CI requirements in normal workflow.
- Require deployments to succeed before merging (Optional)
- Lock branch (Optional - prevents all pushes to branch)
- Do not allow force pushes
- Do not allow deletions
- Click Create button at the bottom
-
Create a test branch:
git checkout -b test/branch-protection echo "test" >> README.md git commit -am "test: verify branch protection" git push origin test/branch-protection
-
Create a Pull Request on GitHub
-
Verify the following:
- ✅ Merge button is disabled with message "Merging is blocked"
- ✅ Status checks section shows: "Required status checks: 11"
- ✅ All 11 CI jobs appear in the status check list
- ✅ After CI completes successfully, merge button becomes enabled
-
Test failed CI scenario:
- Make a commit that breaks linting (e.g., add trailing spaces)
- Push to PR branch
- Verify merge button is disabled again
- Fix the issue and verify merge button re-enables
- Creating feature branches
- Creating Pull Requests
- Pushing commits to PR branches
- Merging PR after all CI checks pass + approval (if required)
- Direct push to
mainbranch - Merging PR while CI is running
- Merging PR with failing CI checks
- Force pushing to
main(if configured) - Deleting
mainbranch (if configured)
Problem: Required status checks don't show up in the search box.
Solution:
- Merge at least one PR to trigger CI workflow
- Wait for all jobs to complete
- Return to Branch Protection settings
- Status check names should now appear in autocomplete
Problem: Merge button is green even with failing CI.
Solution:
- Check that "Require status checks to pass before merging" is enabled
- Verify all 11 status checks are listed in the required checks section
- Confirm "Require branches to be up to date before merging" is checked
Problem: All checks pass but merge is still blocked.
Solution:
- Check if "Require pull request reviews" is enabled and approvals are needed
- Check if "Require conversation resolution" is enabled and comments need resolving
- Verify branch is up-to-date with
main
When adding new CI jobs to .github/workflows/ci.yml:
- Add the job to the workflow file
- Merge the change to
main - Update Branch Protection settings
- Add the new job name to required status checks
When removing CI jobs:
- Update Branch Protection settings first (remove from required checks)
- Then remove the job from workflow file
- Merge the change
- TASK-GHA-011: Branch Protection Rules configuration
- Phase 4: Complete CI/CD implementation
- REQ-GHA-011: Branch protection requirements
Last Updated: 2025-11-17
Status: Phase 4 - Ready for implementation