@@ -20,20 +20,23 @@ jobs:
20
20
uses : actions/checkout@v3
21
21
22
22
- name : Validate branch name
23
- if : ${{ github.event_name != 'pull_request' }} # Skip for PR validation
24
23
run : |
25
- # Define constants
24
+ # Determine the branch name
25
+ if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
26
+ branch_name="${GITHUB_HEAD_REF}"
27
+ else
28
+ branch_name="${GITHUB_REF#refs/heads/}"
29
+ fi
30
+
31
+ # Define the branch name pattern
26
32
PREFIXES="FEATURE|BUGFIX|RELEASE"
27
- SYSTEMS ="HCMPRE|DPG|SN"
33
+ PROJECTS ="HCMPRE|DPG|SN"
28
34
TICKET_PATTERN="[0-9]{1,5}"
29
- BRANCH_PATTERN="^($PREFIXES)\/($SYSTEMS)-$TICKET_PATTERN$"
30
-
31
- # Determine the branch name
32
- branch_name="${GITHUB_REF#refs/heads/}"
33
-
35
+ BRANCH_PATTERN="^($PREFIXES)\/($PROJECTS)-$TICKET_PATTERN$"
36
+
34
37
# Validate the branch name
35
38
if [[ ! "$branch_name" =~ $BRANCH_PATTERN ]]; then
36
- echo "Branch name '$branch_name' does not follow the correct pattern: $PREFIXES/$SYSTEMS -<TICKET_NO> where <TICKET_NO> is $TICKET_PATTERN"
39
+ echo "Branch name '$branch_name' does not follow the correct pattern : $PREFIXES/$PROJECTS -<TICKET_NO> where <TICKET_NO> is $TICKET_PATTERN"
37
40
exit 1
38
41
fi
39
42
@@ -42,15 +45,15 @@ jobs:
42
45
run : |
43
46
# Define constants
44
47
PREFIXES="FEATURE|BUGFIX|RELEASE"
45
- SYSTEMS ="HCMPRE|DPG|SN"
48
+ PROJECTS ="HCMPRE|DPG|SN"
46
49
TICKET_PATTERN="[0-9]{1,5}"
47
- TITLE_PATTERN="^($PREFIXES)\/($SYSTEMS )-$TICKET_PATTERN: .+$"
50
+ TITLE_PATTERN="^($PREFIXES)\/($PROJECTS )-$TICKET_PATTERN .+$"
48
51
49
52
# Get the PR title
50
53
pr_title="${{ github.event.pull_request.title }}"
51
54
52
55
# Validate the PR title
53
56
if [[ ! "$pr_title" =~ $TITLE_PATTERN ]]; then
54
- echo "PR title '$pr_title' does not follow the correct pattern: $PREFIXES/$SYSTEMS -<TICKET_NO>: <Description> where <TICKET_NO> is $TICKET_PATTERN"
57
+ echo "PR title '$pr_title' does not follow the correct pattern: $PREFIXES/$PROJECTS -<TICKET_NO>: <Description> where <TICKET_NO> is $TICKET_PATTERN"
55
58
exit 1
56
59
fi
0 commit comments