-
Notifications
You must be signed in to change notification settings - Fork 3
177 lines (156 loc) · 5.67 KB
/
parsegithubissue.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
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
172
173
174
175
176
177
name: Auto Parse github form
run-name: ${{ github.actor }} - issue:${{ github.event.issue.number }}
on:
issues:
types:
- opened
- edited
workflow_dispatch:
env:
GH_TOKEN: ${{ secrets.PLATFORM_USER_TOKEN }}
permissions:
id-token: write
jobs:
parse:
permissions: write-all
runs-on: ubuntu-latest
if: ${{ github.event.issue.user.login != 'renovate[bot]' }}
steps:
- name: Add eyes reaction
uses: aidan-mundy/[email protected]
with:
issue-number: ${{ github.event.issue.number }}
reactions: eyes
#Uncomment for troubleshooting
#- name: Dump context
#uses: crazy-max/ghaction-dump-context@v2
- name: add processing label
uses: actions-ecosystem/action-add-labels@v1
with:
labels: "Processing"
- name: Remove labels
uses: actions-ecosystem/action-remove-labels@v1
if: env.PROCESS_SUCCESS == 'false'
with:
labels: |
Success
Error in form
High Cost
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'
token: ${{ env.GH_TOKEN }}
- name: Parse issue
id: parse_issue
uses: onmax/[email protected]
with:
issue_number: ${{ github.event.issue.number }}
- name: Show parsed payload data
run: |
# Using the character `'` to prevent all characters enclosed within
# them from being treated as special characters (e.g. $ or `)
echo '${{ steps.parse_issue.outputs.payload }}'
echo NEW_DATA='${{ steps.parse_issue.outputs.payload }}' >> $GITHUB_ENV
echo GITHUB_REPO='${{ github.repository }}' >> $GITHUB_ENV
echo ISSUE_NUMBER='${{ github.event.issue.number }}' >> $GITHUB_ENV
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Python Requirements
run: |
pip3 install -r requirements.txt
- name: process form data
continue-on-error: true
run: |
python ./scripts/file_handling.py
- name: Create Issue Comment
if: env.PROCESS_SUCCESS != 'true'
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.issue.number }}
body: |
${{ env.ISSUE_COMMENT }}
Please edit this issue and select "Update comment" to resubmit.
- name: 'Az CLI login'
uses: azure/login@v1
with:
client-id: 2b6fa9d7-7dba-4600-a58a-5e25554997aa # DTS AKS Auto-Shutdown
tenant-id: 531ff96d-0ae9-462a-8d2d-bec7c0b42082 # HMCTS.NET
allow-no-subscriptions: true
- name: get aks resource details
if: env.PROCESS_SUCCESS == 'true'
continue-on-error: true
run: ./scripts/aks/resource-details.sh
- name: process costs
if: env.PROCESS_SUCCESS == 'true'
continue-on-error: true
run: |
python ./scripts/cost-calculator.py || echo "Calculating cost failed"
- name: Add cost details as a comment
if: env.PROCESS_SUCCESS == 'true' && env.ERROR_IN_COSTS != 'true'
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.issue.number }}
body: |
Total estimated cost of skipping shutdown for the provided dates is **£${{ env.COST_DETAILS_FORMATTED }}**
- name: Add cost error details as a comment
if: env.PROCESS_SUCCESS == 'true' && env.ERROR_IN_COSTS == 'true'
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.issue.number }}
body: |
We have been unable to estimate the cost of this skip request.
- name: Add high cost label
if: env.COST_DETAILS > 1000
uses: actions-ecosystem/action-add-labels@v1
with:
labels: "High Cost"
- name: Add costs error label
if: env.ERROR_IN_COSTS == 'true'
uses: actions-ecosystem/action-add-labels@v1
with:
labels: "Cost Error"
- name: Remove error labels
uses: actions-ecosystem/action-remove-labels@v1
if: env.PROCESS_SUCCESS == 'true'
with:
labels: |
Error in form
Processing
- name: Remove labels
uses: actions-ecosystem/action-remove-labels@v1
if: env.PROCESS_SUCCESS == 'false'
with:
labels: |
Processing
Success
- name: Add success label
if: env.PROCESS_SUCCESS == 'true'
uses: actions-ecosystem/action-add-labels@v1
with:
labels: "Success"
- name: Add error label
if: env.PROCESS_SUCCESS != 'true'
uses: actions-ecosystem/action-add-labels@v1
with:
labels: "Error in form"
- name: Commit to master
if: env.PROCESS_SUCCESS == 'true'
run: |
git config user.name hmcts-platform-operations
git config user.email [email protected]
git add .
git commit -m parseissue-${{ github.event.issue.number }}
git push
commit_tree_url=$(gh browse -c -n)
commit_url=${commit_tree_url/tree/commit}
echo "COMMIT_URL=$(echo $commit_url)" >> $GITHUB_ENV
- name: Close Issue
if: env.PROCESS_SUCCESS == 'true'
uses: peter-evans/close-issue@v3
with:
issue-number: ${{ github.event.issue.number }}
comment: |
Success! Your [commit](${{ env.COMMIT_URL }}) has been added to the json exclusions file.
Auto-closing issue.