Skip to content

Commit 7897c65

Browse files
fix(workflows): enforce standard flow - remove test/* from main allowlist
**BREAKING CHANGE**: test/* branches can no longer merge directly to main **Changes:** 1. Removed test/* from branch allowlist in dev-to-main.yml 2. Only dev and release/* branches can merge to main 3. All feature/*, fix/*, test/* must follow: branch → dev → main **Updated README:** - Clarified "Branch Flow Rules" section - Standard flow (feature/*, fix/*, test/*): must go through dev - Special exceptions (dev, release/*, dependabot/*): can merge to main - Added clear examples and validation warning **Rationale:** Test branches should follow the same quality gates as feature branches. Only production-ready code from dev or emergency hotfixes from release/* should merge directly to main. This corrects the previous implementation that incorrectly allowed test/* branches to bypass dev. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b68d2bb commit 7897c65

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

.github/workflows/dev-to-main.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
# Validates release pull requests before merging to main (production).
55
#
66
# Release Gates:
7-
# - Source must be dev, test/*, or release/* branches
7+
# - Source must be dev or release/* branches
88
# - Production build must succeed
99
# - Smoke tests must pass
1010
# - Security quick scan (informational only)
1111
# - Deployment readiness checklist
1212
#
1313
# Allowed source branches:
14-
# - dev: Production releases
15-
# - test/*: Workflow validation and testing
16-
# - release/*: Hotfix releases
14+
# - dev: Production releases (standard flow)
15+
# - release/*: Emergency hotfix releases
1716
# - dependabot/*: Automated dependency updates
1817
#
18+
# All other branches (feature/*, fix/*, test/*) must merge to dev first.
19+
#
1920
# Author: Alireza Rezvani
2021
# Date: 2025-11-06
2122
# ─────────────────────────────────────────────────────────────────
@@ -67,21 +68,24 @@ jobs:
6768
fi
6869
6970
# Allowlist: branches permitted to merge to main
70-
# Includes: dev (production), test/* (validation), release/* (hotfixes)
71-
ALLOWED_REGEX='^(dev|test/.*|release/.*)$'
71+
# Only: dev (production), release/* (hotfixes)
72+
# All other branches (feature/*, fix/*, test/*) must go through dev first
73+
ALLOWED_REGEX='^(dev|release/.*)$'
7274
7375
if [[ ! $SOURCE_BRANCH =~ $ALLOWED_REGEX ]]; then
7476
echo "❌ Invalid source branch: $SOURCE_BRANCH"
7577
echo ""
76-
echo "Only branches matching the allowlist may be merged to 'main'."
78+
echo "Only dev and release/* branches may be merged to 'main'."
7779
echo ""
7880
echo "Allowed patterns:"
7981
echo " - dev (production releases)"
80-
echo " - test/* (workflow validation)"
81-
echo " - release/* (hotfix releases)"
82+
echo " - release/* (emergency hotfixes)"
8283
echo ""
8384
echo "Got: $SOURCE_BRANCH → main"
8485
echo ""
86+
echo "All other branches (feature/*, fix/*, test/*) must merge to dev first:"
87+
echo " $SOURCE_BRANCH → dev → main"
88+
echo ""
8589
echo "If using a different branching strategy, adjust ALLOWED_REGEX in this workflow."
8690
exit 1
8791
fi

README.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,31 +190,42 @@ The blueprint supports all three strategies out of the box. Choose during setup.
190190

191191
---
192192

193-
## 🔀 Special Branch Patterns
193+
## 🔀 Branch Flow Rules
194194

195-
The `Release to Main` workflow allows specific branch patterns to merge directly to `main`:
195+
The `Release to Main` workflow enforces the following rules:
196+
197+
### Standard Flow (Required for Most Branches)
198+
```
199+
feature/* → dev → main
200+
fix/* → dev → main
201+
test/* → dev → main
202+
```
203+
204+
All feature, fix, and test branches **must** merge to `dev` first, then `dev` merges to `main`.
205+
206+
### Special Exceptions (Direct to Main)
196207

197208
| Pattern | Purpose | Use Case |
198209
|---------|---------|----------|
199-
| `dev` | Production releases | Standard release flow (dev → main) |
200-
| `test/*` | Workflow validation | Testing CI/CD changes (e.g., test/workflow-validation) |
201-
| `release/*` | Hotfix releases | Emergency fixes bypassing dev (e.g., release/1.0.1) |
202-
| `dependabot/*` | Dependency updates | Automated dependency PRs |
210+
| `dev` | Production releases | Standard release flow (only dev can merge to main) |
211+
| `release/*` | Emergency hotfixes | Critical fixes bypassing dev (e.g., release/1.0.1-security) |
212+
| `dependabot/*` | Dependency updates | Automated dependency update PRs |
203213

204214
**Example:**
205215
```bash
206-
# Test workflow changes
207-
git checkout -b test/new-ci-feature
208-
git push origin test/new-ci-feature
209-
# PR to main will run all release gates
216+
# Standard flow (most common)
217+
git checkout -b feature/new-feature
218+
git push origin feature/new-feature
219+
# Create PR: feature/new-feature → dev
220+
# After merge, create PR: dev → main
210221

211-
# Emergency hotfix
222+
# Emergency hotfix (rare)
212223
git checkout -b release/1.0.1-security-patch
213224
git push origin release/1.0.1-security-patch
214-
# PR to main with fast-track release gates
225+
# Create PR: release/1.0.1-security-patch → main (bypasses dev)
215226
```
216227

217-
All other branches must follow the standard flow (feature/* → dev → main).
228+
**Important**: Attempting to merge feature/*, fix/*, or test/* branches directly to `main` will fail validation.
218229

219230
---
220231

0 commit comments

Comments
 (0)