File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : PR Target Branch Check
2+
3+ on :
4+ pull_request :
5+ branches : [main, dev]
6+
7+ jobs :
8+ check-target-branch :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - name : Enforce branch targeting rules
12+ run : |
13+ SOURCE="${{ github.head_ref }}"
14+ TARGET="${{ github.base_ref }}"
15+
16+ echo "Source branch: $SOURCE"
17+ echo "Target branch: $TARGET"
18+
19+ if [ "$TARGET" = "main" ] && [ "$SOURCE" != "dev" ]; then
20+ echo ""
21+ echo "========================================"
22+ echo "FAILED: Only 'dev' branch can target 'main'."
23+ echo ""
24+ echo "Your branch '$SOURCE' must target 'dev' instead."
25+ echo "Please change the base branch of this PR to 'dev'."
26+ echo "========================================"
27+ exit 1
28+ fi
29+
30+ echo ""
31+ echo "========================================"
32+ echo "PASSED: Branch targeting rule satisfied."
33+ echo "========================================"
You can’t perform that action at this time.
0 commit comments