Skip to content

Commit ab24a17

Browse files
fix(workflows): allow test/* and release/* branches + fix status logic
**Branch Allowlist:** - Added regex pattern to allow dev, test/*, and release/* branches - test/* branches: for workflow validation and testing - release/* branches: for hotfix releases - dependabot/* branches: still bypass validation - Clear error messages explaining allowed patterns **Release Gate Status Logic:** - Fixed bug where 'skipped' status was treated as success - Now treats ANY status other than 'success' as blocking - Includes detailed gate results in error message - Shows actual status of each gate (success/skipped/failure/cancelled) **Documentation:** - Updated header comment with new branch policy - Added clear explanations in validation messages This fixes PR #7 (test/workflow-validation) and future test/release PRs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4b9b845 commit ab24a17

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

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

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
# ─────────────────────────────────────────────────────────────────
2-
# Dev to Main Workflow (Release Gates)
2+
# Release to Main Workflow (Release Gates)
33
# ─────────────────────────────────────────────────────────────────
44
# Validates release pull requests before merging to main (production).
55
#
66
# Release Gates:
7-
# - Source must be 'dev' branch only
7+
# - Source must be dev, test/*, or release/* branches
88
# - Production build must succeed
99
# - Smoke tests must pass
1010
# - Security quick scan (informational only)
1111
# - Deployment readiness checklist
1212
#
13+
# Allowed source branches:
14+
# - dev: Production releases
15+
# - test/*: Workflow validation and testing
16+
# - release/*: Hotfix releases
17+
# - dependabot/*: Automated dependency updates
18+
#
1319
# Author: Alireza Rezvani
1420
# Date: 2025-11-06
1521
# ─────────────────────────────────────────────────────────────────
@@ -60,19 +66,27 @@ jobs:
6066
exit 0
6167
fi
6268
63-
if [[ "$SOURCE_BRANCH" != "dev" ]]; then
69+
# Allowlist: branches permitted to merge to main
70+
# Includes: dev (production), test/* (validation), release/* (hotfixes)
71+
ALLOWED_REGEX='^(dev|test/.*|release/.*)$'
72+
73+
if [[ ! $SOURCE_BRANCH =~ $ALLOWED_REGEX ]]; then
6474
echo "❌ Invalid source branch: $SOURCE_BRANCH"
6575
echo ""
66-
echo "Only 'dev' branch can be merged to 'main' for releases."
76+
echo "Only branches matching the allowlist may be merged to 'main'."
77+
echo ""
78+
echo "Allowed patterns:"
79+
echo " - dev (production releases)"
80+
echo " - test/* (workflow validation)"
81+
echo " - release/* (hotfix releases)"
6782
echo ""
68-
echo "Expected: dev → main"
6983
echo "Got: $SOURCE_BRANCH → main"
7084
echo ""
71-
echo "If using a different branching strategy, adjust this workflow."
85+
echo "If using a different branching strategy, adjust ALLOWED_REGEX in this workflow."
7286
exit 1
7387
fi
7488
75-
echo "✅ Source branch is valid: dev → main"
89+
echo "✅ Source branch is valid: $SOURCE_BRANCH → main"
7690
7791
# ─────────────────────────────────────────────────────────────────
7892
# Production Build Validation
@@ -397,14 +411,26 @@ jobs:
397411
398412
echo "" >> $GITHUB_STEP_SUMMARY
399413
400-
# Overall status
401-
if [[ "${{ needs.validate-source.result }}" == "failure" ]] || \
402-
[[ "${{ needs.build-prod.result }}" == "failure" ]] || \
403-
[[ "${{ needs.smoke-tests.result }}" == "failure" ]] || \
404-
[[ "${{ needs.deployment-readiness.result }}" == "failure" ]]; then
414+
# Overall status - check if ALL gates passed
415+
# Treat anything other than "success" as blocking (including "skipped", "failure", "cancelled")
416+
VALIDATE_RESULT="${{ needs.validate-source.result }}"
417+
BUILD_RESULT="${{ needs.build-prod.result }}"
418+
SMOKE_RESULT="${{ needs.smoke-tests.result }}"
419+
DEPLOY_RESULT="${{ needs.deployment-readiness.result }}"
420+
421+
if [[ "$VALIDATE_RESULT" != "success" ]] || \
422+
[[ "$BUILD_RESULT" != "success" ]] || \
423+
[[ "$SMOKE_RESULT" != "success" ]] || \
424+
[[ "$DEPLOY_RESULT" != "success" ]]; then
405425
echo "## ❌ Release Blocked" >> $GITHUB_STEP_SUMMARY
406426
echo "" >> $GITHUB_STEP_SUMMARY
407-
echo "One or more release gates failed. Please fix the issues before merging to production." >> $GITHUB_STEP_SUMMARY
427+
echo "One or more release gates did not pass. Please fix the issues before merging to production." >> $GITHUB_STEP_SUMMARY
428+
echo "" >> $GITHUB_STEP_SUMMARY
429+
echo "**Gate Results:**" >> $GITHUB_STEP_SUMMARY
430+
echo "- Source validation: $VALIDATE_RESULT" >> $GITHUB_STEP_SUMMARY
431+
echo "- Production build: $BUILD_RESULT" >> $GITHUB_STEP_SUMMARY
432+
echo "- Smoke tests: $SMOKE_RESULT" >> $GITHUB_STEP_SUMMARY
433+
echo "- Deployment readiness: $DEPLOY_RESULT" >> $GITHUB_STEP_SUMMARY
408434
exit 1
409435
else
410436
echo "## ✅ Release Approved" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)