-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (74 loc) · 3.12 KB
/
jira-lint.yaml
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Run Jira Linter
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_call:
inputs:
fail-on-error:
type: string
description: A Boolean which, if set to true, fails the GitHub Action when an error occurs. Default true.
default: 'true'
skip-comments:
type: string
description: A Boolean if set to true then action-jira-linter will skip adding lint comments for PR title.
default: 'false'
secrets:
JIRA_TOKEN:
required: true
env:
githubPrBranch: ${{ github.head_ref }}
githubPrTitle: ${{ github.event.pull_request.title }}
jobs:
jira-lint:
name: Run Jira Lint
if: ${{ github.actor != 'amutechtest' && github.actor != 'dependabot[bot]' && !contains(github.head_ref, 'sync') && !contains(github.event.pull_request.labels.*.name, 'disable-jira-linter') }}
runs-on: ubuntu-latest
steps:
- name: Retrieve Jira issue key from PR
id: jira-ticket
run: |
PR_BRANCH=$(echo "${{ env.githubPrBranch }}" | grep -Eio "\b[A-Z][A-Z0-9_]+-[1-9][0-9]*" || true)
PR_TITLE=$(echo "${{ env.githubPrTitle }}" | grep -Eio "\b[A-Z][A-Z0-9_]+-[1-9][0-9]*" || true)
for var in ${PR_BRANCH} ${PR_TITLE}; do JIRA_TICKET_ID=$(echo $var | grep -E ".") && break ; done
if [ -z "${JIRA_TICKET_ID}" ]; then
if [ "${{ inputs.fail-on-error }}" = "true" ]; then
echo "::error::A Jira issue key is missing from your branch name and pull request title. Please confirm it is linked properly in the pull request."
exit 1
else
echo "::warning::A Jira issue key is missing from your branch name and pull request title. Please confirm it is linked properly in the pull request."
echo "ticket-found=false" >> $GITHUB_OUTPUT
fi
fi
- name: Check if missing Jira issue key comment exists
if: ${{ steps.jira-ticket.outputs.ticket-found != 'false' }}
id: comment
uses: peter-evans/find-comment@v2
with:
issue-number: ${{ github.event.number }}
body-includes: A JIRA Issue ID is missing from your branch name!
direction: last
- uses: jira-tools/action-jira-linter@v1.0.1
if: ${{ ! steps.comment.outputs.comment-body && steps.jira-ticket.outputs.ticket-found != 'false' }}
name: Jira Lint
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
jira-token: ${{ secrets.JIRA_TOKEN }}
jira-base-url: https://amuniversal.atlassian.net
pr-threshold: 1000
jira-user: amu_deploy@amuniversal.com
validate-issue-status: true
allowed-issue-statuses: |
New
Reopened
To Do
In Progress
Peer Review
In Staging / QA
Ready for Staging
Ready For Staging
In Development Env
Approved
Resolved
skip-branches: "^(main|development|staging|production|dev)$"
fail-on-error: ${{ inputs.fail-on-error }}
skip-comments: ${{ inputs.skip-comments }}