-
Notifications
You must be signed in to change notification settings - Fork 16
29 lines (26 loc) · 1.03 KB
/
branch.name.validation.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
name: Branch Name Validation
on:
create:
# Trigger this workflow only when a branch or tag is created
branches:
- '*'
tags:
- '*'
jobs:
branch_name_validation:
runs-on: ubuntu-latest
steps:
- name: Check Branch Name
id: check_branch
run: |
ref="${GITHUB_REF}"
if [[ "$ref" =~ ^refs/heads/ ]]; then
branch_name="${ref#refs/heads/}"
if ! [[ "$branch_name" =~ ^(main|(release/[0-9\.]+)|(issue/[0-9]+)|(suggestion/[0-9]+)|(feature/[a-z0-9\-]+)|(dev/[a-z0-9\-]+))$ ]]; then
echo "Invalid branch name: $branch_name"
echo "Allowed patterns: main, release/x.y.z, issue/123, suggestion/123, feature/feature-name, dev/branch-name"
exit 1
fi
else
echo "Skipping tag event: $ref"
fi