-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathissue-status-update-from-jira.yml
More file actions
117 lines (104 loc) · 4.1 KB
/
issue-status-update-from-jira.yml
File metadata and controls
117 lines (104 loc) · 4.1 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# This is a basic workflow to help you get started with Actions
name: Update Github Issue Status
# Controls when the workflow will run
on:
workflow_call:
workflow_dispatch:
inputs:
jira_ticket:
type: string
description: Jira ticket number
required: true
ticket_status:
type: choice
description: Jira ticket status
required: true
options:
- Open
- To Do
- In Progress
- In Review
- In Validation
- Blocked
- Ice Box
- Backlog
- Done
- Won't Do
repository_dispatch:
jobs:
update-issue-status:
runs-on: ubuntu-latest
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
steps:
- name: Login
uses: atlassian/gajira-login@master
- name: Get Jira Ticket Links
uses: fjogeleit/http-request-action@v1.16.5
id: get_links
with:
url: ${{ env.JIRA_BASE_URL }}/rest/api/2/issue/${{ github.event.inputs.jira_ticket }}/remotelink
method: GET
username: ${{ env.JIRA_USER_EMAIL }}
password: ${{ env.JIRA_API_TOKEN }}
customHeaders: '{"Content-Type": "application/json"}'
- run: echo ${{ steps.get_links.outputs.response }}
- name: Parse URL from List
id: parse_url
run: |
echo ::set-output name=issue_url::`echo '${{ steps.get_links.outputs.response }}' | jq '.[]|select(.object.title | startswith("Github Issue Link:")).object.url'`
- uses: mad9000/actions-find-and-replace-string@2
id: sub
with:
source: '${{ steps.parse_url.outputs.issue_url }}'
find: github.com
replace: api.github.com/repos
- run: echo ${{ steps.sub.outputs.value }}
- name: Set variable closed
id: set_variable
if: contains(fromJson('["Done", "Won\u0027t Do"]'), github.event.inputs.ticket_status)
run: echo "ticket_status=closed" >> $GITHUB_OUTPUT
- name: Set Ticket Status Open
if: ${{ steps.set_variable.outputs.ticket_status != 'closed' }}
run: |
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{secrets.MP_SEMANTIC_RELEASE_BOT}}" \
${{ steps.sub.outputs.value }} \
-d '{"state":"open"}'
- name: Set Ticket Status, Wont do
if: contains(fromJson('["Won\u0027t Do"]'), github.event.inputs.ticket_status)
run: |
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{secrets.MP_SEMANTIC_RELEASE_BOT}}" \
${{ steps.sub.outputs.value }} \
-d '{"state":"closed", "state_reason":"not_planned"}'
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{secrets.MP_SEMANTIC_RELEASE_BOT}}" \
${{ steps.sub.outputs.value }}/comments \
-d '{"body":"mParticle ticket status has been changed to Wont Do"}'
- name: Set Ticket Status Closed
if: ${{ steps.set_variable.outputs.ticket_status == 'closed' && (contains(fromJson('["Done"]'), github.event.inputs.ticket_status))}}
run: |
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{secrets.MP_SEMANTIC_RELEASE_BOT}}" \
${{ steps.sub.outputs.value }} \
-d '{"state":"closed"}'
- name: Comment status
if: ${{ steps.set_variable.outputs.ticket_status != 'closed' || (contains(fromJson('["Done"]'), github.event.inputs.ticket_status))}}
run: |
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{secrets.MP_SEMANTIC_RELEASE_BOT}}" \
${{ steps.sub.outputs.value }}/comments \
-d '{"body":"mParticle ticket status has been changed to ${{ github.event.inputs.ticket_status }}"}'