-
-
Notifications
You must be signed in to change notification settings - Fork 5
36 lines (30 loc) · 1.13 KB
/
branch-rules.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: Branch Rules
on:
pull_request:
branches:
- main
- develop
- production
jobs:
check_branch_rules:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check PR Source and Target
run: |
# Không cho phép PR từ production vào main
if [[ "${{ github.head_ref }}" == "production" && "${{ github.base_ref }}" == "main" ]]; then
echo "❌ Pull requests from production to main are not allowed"
exit 1
fi
# Chỉ cho phép merge vào production từ main
if [[ "${{ github.base_ref }}" == "production" && "${{ github.head_ref }}" != "main" ]]; then
echo "❌ Only main branch can be merged into production"
exit 1
fi
# Feature branches chỉ có thể merge vào develop
if [[ "${{ github.head_ref }}" =~ ^feature/ && "${{ github.base_ref }}" != "develop" ]]; then
echo "❌ Feature branches can only be merged into develop"
exit 1
fi
echo "✅ Branch rules check passed"