-
Notifications
You must be signed in to change notification settings - Fork 18
171 lines (153 loc) · 6.66 KB
/
issues.yml
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
---
name: Create JIRA ticket for new issues
on:
issues:
types: [opened, reopened, closed]
permissions:
issues: write
contents: read
jobs:
jira_task:
name: Create Jira issue
if: github.event.action == 'opened'
runs-on: ubuntu-latest
steps:
- name: Create JIRA ticket
id: create
shell: bash
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_URL: ${{ github.event.issue.html_url }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_ASSIGNEE: ${{ secrets.ASSIGNEE_JIRA_TICKET }}
run: |
json_response=$(curl --request POST \
--url 'https://jira.mongodb.org/rest/api/2/issue' \
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"fields": {
"project": {
"id": "10984"
},
"summary": "HELP: GitHub Issue n. '"${ISSUE_NUMBER}"'",
"issuetype": {
"id": "12"
},
"customfield_12751": [{
"id": "25550"
}],
"description": "This ticket tracks the following GitHub issue: '"${ISSUE_URL}"'.",
"components": [
{
"id": "34031"
}
]
}
}')
echo "Response: ${json_response}"
JIRA_TICKET_ID=$(echo "${json_response}" | jq -r '.key')
echo "The following JIRA ticket has been created: ${JIRA_TICKET_ID}"
echo "jira-ticket-id=${JIRA_TICKET_ID}" >> "${GITHUB_OUTPUT}"
- name: Add comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
with:
issue-number: ${{ github.event.issue.number }}
body: |
Thanks for opening this issue! Please make sure to provide the following information to help us reproduce the issue:
- CDK code used by the customer
- The output of [cdk synth](https://cdkworkshop.com/30-python/20-create-project/400-synth.html)
- List of Public CFN Resources that are activated in the AWS account with their release version
- AWS Region where the CFN stack is running
Thanks for opening this issue. The ticket [${{ steps.create.outputs.jira-ticket-id }}](https://jira.mongodb.org/browse/${{ steps.create.outputs.jira-ticket-id }}) was created for internal tracking.
reopen_jira_ticket:
name: Reopen JIRA ticket
if: github.event.action == 'reopened'
runs-on: ubuntu-latest
steps:
- name: Reopened JIRA ticket if exists
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
JIRA_API_TOKEN=${{ secrets.JIRA_API_TOKEN }}
JIRA_QUERY="project = CLOUDP AND issuetype = Story AND resolution = Declined AND text ~ \"HELP: GitHub Issue n. $ISSUE_NUMBER\""
# URL encode the query
JIRA_URL=$(echo "$JIRA_QUERY" | jq -s -R -r @uri)
json_response=$(curl -s --request GET \
--url "https://jira.mongodb.org/rest/api/2/search?fields=id&jql=${JIRA_URL}" \
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
--header 'Accept: application/json')
JIRA_TICKET_ID=$(echo "${json_response}" | jq -r '.issues[0].id')
if [ -z "$JIRA_TICKET_ID" ]; then
echo "JIRA_TICKET_ID is not defined. Exiting the script."
exit 1
fi
JIRA_REOPENED_URL="https://jira.mongodb.org/rest/api/2/issue/${JIRA_TICKET_ID}/transitions"
json_response=$(curl -s --request POST \
--url "${JIRA_REOPENED_URL}" \
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"transition": {
"id": 3
},
"update": {
"comment": [
{
"add": {
"body": "The related GitHub issue was reopened. Updated via automated process."
}
}
]
}
}')
echo "Response: ${json_response}"
close_jira_ticket:
name: Close JIRA ticket
if: github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Close JIRA ticket if exists
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
JIRA_API_TOKEN=${{ secrets.JIRA_API_TOKEN }}
JIRA_QUERY="project = CLOUDP AND issuetype = Story AND resolution = Unresolved AND text ~ \"HELP: GitHub Issue n. $ISSUE_NUMBER\""
# URL encode the query
JIRA_URL=$(echo "$JIRA_QUERY" | jq -s -R -r @uri)
json_response=$(curl -s --request GET \
--url "https://jira.mongodb.org/rest/api/2/search?fields=id&jql=${JIRA_URL}" \
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
--header 'Accept: application/json')
JIRA_TICKET_ID=$(echo "${json_response}" | jq -r '.issues[0].id')
if [ -z "$JIRA_TICKET_ID" ]; then
echo "JIRA_TICKET_ID is not defined. Exiting the script."
exit 1
fi
JIRA_CLOSE_URL="https://jira.mongodb.org/rest/api/2/issue/${JIRA_TICKET_ID}/transitions"
json_response=$(curl -s --request POST \
--url "${JIRA_CLOSE_URL}" \
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"transition": {
"id": 1371
},
"update": {
"comment": [
{
"add": {
"body": "The related GitHub issue was closed. Resolved via automated process."
}
}
]
},
"fields": {
"resolution": {
"name": "Declined"
}
}
}')
echo "Response: ${json_response}"