-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (36 loc) · 1.32 KB
/
pull-request.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
37
38
39
40
name: pull request
on:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- dev
- main
jobs:
check-pull-request:
runs-on: ubuntu-latest
steps:
- name: Check branch prefix
run: |
BRANCH_NAME=${GITHUB_HEAD_REF}
TARGET_BRANCH=${GITHUB_BASE_REF}
if [[ "$TARGET_BRANCH" == "dev" ]]; then
if [[ "$BRANCH_NAME" =~ ^feature/|^release/|^hotfix/ ]]; then
echo "Branch name is valid for dev."
else
echo "Error: Branch name for dev must start with 'feature/', 'release/', or 'hotfix/'."
exit 1
fi
elif [[ "$TARGET_BRANCH" == "main" ]]; then
if [[ "$BRANCH_NAME" =~ ^release/|^hotfix/ ]]; then
echo "Branch name is valid for main."
else
echo "Error: Branch name for main must start with 'release/' or 'hotfix/'."
exit 1
fi
else
echo "Error: Unsupported target branch."
exit 1
fi