The branch protection rule "Changes must be made through a pull request" is incorrectly being applied to PR feature branches (e.g., HDC-1960). This rule should only protect the main branches (main and release), not feature branches used for pull requests.
- Pushing to feature branches like
HDC-1960triggers "Bypassed rule violations" warning - The push succeeds because of admin override permissions, but this indicates misconfiguration
- Feature branches should allow direct pushes as part of the normal PR workflow
Branch protection rules are configured in GitHub's UI (Settings → Branches), not in repository files. The current configuration likely:
- Applies protection to all branches (including feature branches), OR
- Uses a pattern that matches feature branch naming conventions (e.g.,
HDC-*), OR - Lacks proper exclusions for PR/feature branches
Configuration:
- Create separate branch protection rules for:
main(production branch)release(staging branch)
- Do NOT apply protection to feature branches
Steps:
- Navigate to:
https://github.com/Honeybee-Health/apiary/settings/branches - Review existing rules
- Ensure rules only target
mainandrelease - Remove or modify any rules that apply to feature branches
Settings for main branch:
- ✅ Require a pull request before merging
- ✅ Require approvals (configure as needed)
- ✅ Require status checks to pass before merging
- ✅ Require branches to be up to date before merging
- ✅ Include administrators
- ❌ Do NOT allow force pushes
- ❌ Do NOT allow deletions
Settings for release branch:
- ✅ Require a pull request before merging
- ✅ Require approvals (may be less strict than main)
- ✅ Require status checks to pass before merging
- ✅ Require branches to be up to date before merging
- ✅ Include administrators
⚠️ Consider allowing force pushes if needed for hotfixes (with caution)
If you need pattern-based protection, configure exclusions:
Protected Pattern: * (all branches)
Exclusions:
HDC-*(Hive feature branches)KEEP-*(Keeper feature branches)PZR-*(Partners feature branches)DEVOPS-*(DevOps feature branches)COL-*(Colony feature branches)DASH-*(Dashboard feature branches)
Note: GitHub branch protection doesn't support wildcard exclusions directly. You'll need to:
- Use specific branch name rules instead, OR
- Apply protection only to
mainandreleaseexplicitly
If you must protect all branches:
- Enable "Allow force pushes" for feature branches (not recommended)
- Use GitHub Actions to automatically allow pushes to branches with open PRs (complex)
Based on codebase analysis, feature branches follow these patterns:
HDC-*- Hive-related ticketsKEEP-*- Keeper-related ticketsPZR-*- Partners-related ticketsDEVOPS-*- DevOps-related ticketsCOL-*- Colony-related ticketsDASH-*- Dashboard-related tickets
These branches are used for pull requests and should allow direct pushes.
After updating branch protection:
-
Test feature branch push:
git checkout -b test-branch-protection git commit --allow-empty -m "Test branch protection" git push origin test-branch-protection- Should NOT show "bypassed rule violations"
- Should succeed without warnings
-
Test protected branch push:
git checkout main git commit --allow-empty -m "Test main protection" git push origin main- Should be blocked (unless you have admin override)
- Should require PR workflow
-
Verify PR workflow:
- Create PR from feature branch to
main - Ensure PR requires approvals and status checks
- Verify merge is blocked until requirements are met
- Create PR from feature branch to
The repository uses:
- Mono-repo structure with multiple Rails apps
- PR-based workflow with feature branches
- Automated CI/CD via GitHub Actions
- JIRA integration for ticket tracking
- Environment deployments based on branch (main → production, release → staging)
Branch protection should support this workflow, not hinder it.
- ✅ Review current branch protection rules in GitHub Settings
- ✅ Update rules to only protect
mainandrelease - ✅ Remove any rules applying to feature branch patterns
- ✅ Test pushing to a feature branch (should work without warnings)
- ✅ Verify
mainandreleaseare still properly protected - ✅ Document the final configuration for team reference
.github/workflows/build.yml- CI/CD workflow.github/workflows/cleanup-pr-env.yml- PR environment cleanup.github/PULL_REQUEST_TEMPLATE/- PR templates
- Branch protection rules are repository-level settings, not code
- Changes require repository admin access
- Consider documenting branch protection policy in repository README or wiki
- The "bypassed rule violations" message indicates admin override, which should only be used in emergencies