-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
43 lines (43 loc) · 1.59 KB
/
action.yml
File metadata and controls
43 lines (43 loc) · 1.59 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
name: 'Jira Check Issue Status'
description: 'check the Jira issue status'
author: 'Mahmoud Almasri'
inputs:
organization-name:
description: 'The name of the organization on Jira'
required: true
default: 'knawat'
jira-token:
description: 'Jira Token'
required: true
runs:
using: "composite"
steps:
- name: Extract Issue name
shell: bash
run: |
if [[ "$(echo ${GITHUB_HEAD_REF} | cut -d "/" -f1)" =~ (feature|hotfix|bugfix) && ! "$(echo ${GITHUB_HEAD_REF} | cut -d "/" -f2)" =~ [A-Z]+-[0-9]+ ]]; then
echo "Your PR is not connected to an issue on Jira, please create an issur for it."
exit 1
else
echo "##[set-output name=name;]$(echo ${GITHUB_HEAD_REF} | grep -Eo '[A-Z]+-[0-9]+')"
fi
id: issue_name
- name: Get Issue Status
shell: bash
run: |
Response=$(curl --location --request GET "https://${{ inputs.organization-name }}.atlassian.net/rest/api/3/issue/${{steps.issue_name.outputs.name}}?fields=status" \
--header 'Accept: application/json' \
--header "Authorization: ${{ inputs.jira-token }}" )
echo "##[set-output name=status;]$(echo $Response | jq '.fields.status.name')"
echo $Response | jq '.fields.status.name'
id: issue_status
- name: Try to fail
shell: bash
run: |
if [[ ! ${{steps.issue_status.outputs.status}} =~ "Done" ]]; then
echo "Your issue on JIRA still not Active."
exit 1
fi
branding:
icon: 'check-circle'
color: 'orange'