-
Notifications
You must be signed in to change notification settings - Fork 0
30 lines (24 loc) · 1.03 KB
/
branch-name-check.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
name: Branch Name Check
on:
pull_request:
types: [opened, synchronize]
jobs:
branch_name_check:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
id: extract_branch
run: echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV
- name: Check branch name format
run: |
# Retrieve the branch name from the environment
BRANCH_NAME=$BRANCH_NAME
# Convert branch name to lowercase
BRANCH_NAME_LOWER=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]')
echo "Branch name: $BRANCH_NAME_LOWER"
# Validate the lowercase branch name
if [[ ! "$BRANCH_NAME_LOWER" =~ ^(bugfix|feature|hotfix|chore|release|test|doc|refactor)/issue-[0-9]+[/-][a-z0-9_-]+$ ]]; then
echo "Branch name $BRANCH_NAME_LOWER does not follow the required pattern: branch-type/issue-###/short-description"
echo "branch-type must be one of: bugfix, feature, hotfix, chore, release, test, doc, refactor"
exit 1
fi