feat: guard main against direct-from-feature-branch PRs - #82
Merged
Conversation
Adds a required-status-check workflow that fails a pull request targeting main unless its head branch is next or matches hotfix-*, per ADR-0008's next -> main branching model (z-shell/.github). This is a required status check, not a full enforcement by itself; wiring it into main's ruleset is a follow-up once the check has run at least once on a real PR. Closes #81
There was a problem hiding this comment.
Pull request overview
Adds a GitHub Actions workflow intended to enforce the repo’s next -> main (and hotfix-* -> main) branching model by failing pull requests that target main from disallowed source branches.
Changes:
- Introduce a new workflow that runs on PRs targeting
mainand validates the PR head branch name (nextorhotfix-*). - Add concurrency settings to avoid redundant runs per PR.
Comment on lines
+21
to
+30
| - name: Verify pull request source branch | ||
| env: | ||
| HEAD_REF: ${{ github.head_ref }} | ||
| run: | | ||
| if [[ "${HEAD_REF}" == "next" || "${HEAD_REF}" == hotfix-* ]]; then | ||
| echo "Head branch '${HEAD_REF}' is allowed to target main." | ||
| exit 0 | ||
| fi | ||
| echo "::error::Pull requests into main must come from 'next' or a 'hotfix-*' branch (got '${HEAD_REF}'). See ADR-0008 (z-shell/.github) for the branching model." | ||
| exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
.github/workflows/main-branch-guard.yml: a required-status-check workflow that fails a pull request targetingmainunless its head branch isnextor matcheshotfix-*, per ADR-0008'snext->mainbranching model (z-shell/.github).This addresses the root cause of #79: PRs #66, #67, #72, #73 were merged directly into
mainfrom feature branches, bypassingnext, which is what causedmainandnextto diverge.This PR only adds the check. Wiring it into
main's ruleset as a required status check is a follow-up, once the check has run at least once on a real PR againstmain(needed so GitHub has a context to reference).Closes #81
Test plan
python3 -c "import yaml; yaml.safe_load(...)"