Skip to content

Commit 8c6d160

Browse files
committed
ci: add PR target check workflow — enforce develop-only PRs to master
1 parent f6f7f25 commit 8c6d160

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: PR Target Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, edited, synchronize]
6+
7+
jobs:
8+
check-target:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Enforce branch strategy
12+
run: |
13+
BASE="${{ github.event.pull_request.base.ref }}"
14+
HEAD="${{ github.event.pull_request.head.ref }}"
15+
16+
echo "PR: $HEAD → $BASE"
17+
18+
if [ "$BASE" = "master" ] && [ "$HEAD" != "develop" ]; then
19+
echo "❌ Only the 'develop' branch can open PRs to 'master'."
20+
echo " Please target 'develop' instead."
21+
exit 1
22+
fi
23+
24+
if [ "$BASE" = "develop" ] && [ "$HEAD" = "master" ]; then
25+
echo "❌ Do not merge 'master' back into 'develop'."
26+
exit 1
27+
fi
28+
29+
echo "✅ PR target is valid: $HEAD → $BASE"

0 commit comments

Comments
 (0)