-
Notifications
You must be signed in to change notification settings - Fork 3
84 lines (81 loc) · 3.26 KB
/
jira-feat.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
82
83
84
name: Communicate feature back to JIRA
on:
workflow_call:
secrets:
JIRA_AUTH: { required: true }
pull_request_review:
types: [submitted]
env:
FEATURE_NAME: ${{ github.event.pull_request.head.ref }}
jobs:
update-jira-issue:
runs-on: ubuntu-latest
environment:
name: development
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get JIRA Issue Key
id: extract_jira_key
run: |
echo "JIRA_KEY=$(echo "$FEATURE_NAME" | grep -oE 'NDT-[0-9]+')" >> $GITHUB_ENV
- name: Update JIRA Issue
# JIRA_AUTH must be passed pre encoded
run: |
FEATURE_NAME_LOWER=$(echo $FEATURE_NAME | tr '[:upper:]' '[:lower:]')
FEATURE_NAME_LOWER_SHORT=$(echo $FEATURE_NAME_LOWER | cut -c -30)
curl -X POST \
-H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \
-H "Content-Type: application/json" \
-d '{
"body": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "AUTOMATIC COMMENT: ",
"type": "text",
"marks": [
{
"type": "strong"
}
]
},
{
"text": "Feature deployed! URL: ",
"type": "text"
},
{
"text": "https://'$FEATURE_NAME_LOWER_SHORT'.apps.silver.devops.gov.bc.ca",
"type": "text",
"marks": [
{
"type": "link",
"attrs": {
"href": "https://'$FEATURE_NAME_LOWER_SHORT'.apps.silver.devops.gov.bc.ca",
"title": "https://'$FEATURE_NAME_LOWER_SHORT'.apps.silver.devops.gov.bc.ca"
}
}
]
}
]
}
]
}
}' \
"https://connectivitydivision.atlassian.net/rest/api/3/issue/$JIRA_KEY/comment"
- name: Transition Issue
if: github.event.review.state == 'approved'
run: |
curl -X POST \
-H "Authorization: Basic ${{ secrets.JIRA_AUTH }}" \
-H "Content-Type: application/json" \
-d '{
"transition": {
"id": "10"
}
}' \
"https://connectivitydivision.atlassian.net/rest/api/3/issue/$JIRA_KEY/transitions"