-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (53 loc) · 2.23 KB
/
pr_title_check.yml
File metadata and controls
58 lines (53 loc) · 2.23 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: PR Title Check
on:
workflow_call:
permissions: {}
jobs:
pr_title_format_check:
runs-on: ubuntu-22.04
permissions:
pull-requests: write
steps:
- name: Check PR Title is Prefixed with Change Type
id: check_prefix
continue-on-error: true
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
if [[ "$PR_TITLE" =~ ^(Fix|Update|New|Breaking|Docs|Build|Upgrade|Chore):.*$ ]]; then
echo "PR title is prefixed with change type."
else
echo "PR title is not prefixed with change type."
exit 1
fi
- name: Check PR Title contains Ticket/Dependabot Reference
id: check_ticket_reference
continue-on-error: true
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
if [[ "$PR_TITLE" =~ ^.*:.*\[([A-Z]+-[0-9]+|dependabot)\].*-.*$ ]]; then
echo "PR title contains ticket or dependabot reference."
else
echo "PR title does not contain ticket or dependabot reference."
exit 1
fi
- name: Extract Ticket Reference
id: extract_ticket_reference
if: steps.check_ticket_reference.outcome == 'success'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
if [[ "$PR_TITLE" =~ ^.*:.*\[([A-Z]+-[0-9]+|dependabot)\].*-.*$ ]]; then
TICKET_REF="${BASH_REMATCH[1]}"
echo "Extracted ticket reference: $TICKET_REF"
echo "TICKET_REF=$TICKET_REF" > "$GITHUB_OUTPUT"
else
echo "No ticket reference found."
exit 1
fi
- name: Fail job due to invalid PR title format
if: steps.check_prefix.outcome != 'success' || steps.check_ticket_reference.outcome != 'success'
run: |
echo "Job failed due to invalid PR title format."
exit 1