-
Notifications
You must be signed in to change notification settings - Fork 5
38 lines (30 loc) Β· 1.32 KB
/
jira-pr-check.yml
File metadata and controls
38 lines (30 loc) Β· 1.32 KB
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
name: Enforce Jira Key in PR Title and Branch
on:
pull_request:
types: [opened, edited, synchronize, reopened]
jobs:
check-jira-key:
runs-on: ubuntu-latest
steps:
- name: Check PR title and branch name for Jira issue key
run: |
echo "π Checking PR title and branch name..."
JIRA_PATTERN="DTSW-[0-9]{4,}"
TITLE="${{ github.event.pull_request.title }}"
BRANCH="${{ github.event.pull_request.head.ref }}"
echo "π PR Title: $TITLE"
echo "π Branch: $BRANCH"
TITLE_OK=$(echo "$TITLE" | grep -E "$JIRA_PATTERN" || true)
BRANCH_OK=$(echo "$BRANCH" | grep -E "$JIRA_PATTERN" || true)
if [ -z "$TITLE_OK" ] && [ -z "$BRANCH_OK" ]; then
echo "β Neither PR title nor branch name contains a valid Jira issue key (DTSW-XXXX)"
echo "π« Merge blocked: Jira issue key must be present in either PR title or branch name"
exit 1
fi
if [ -n "$TITLE_OK" ] && [ -n "$BRANCH_OK" ]; then
echo "β
Jira issue key found in both PR title and branch name."
elif [ -n "$TITLE_OK" ]; then
echo "β
Jira issue key found in PR title."
elif [ -n "$BRANCH_OK" ]; then
echo "β
Jira issue key found in branch name."
fi