-
Notifications
You must be signed in to change notification settings - Fork 0
336 lines (298 loc) · 16.2 KB
/
triggerTest.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
on:
repository_dispatch:
types: [on-demand-payload]
permissions:
id-token: write
contents: read
jobs:
run_if_payload:
if: ${{ github.event }}
runs-on: ubuntu-latest
steps:
- run: |
set -x
export
- name: Turn on build light
run: |
curl -s -o /dev/null "https://kasarest.freshbrewed.science/on?devip=192.168.1.3&apikey=${{ secrets.KASAAPIKEY }}"
- env:
MESSAGE: ${{ github.event.client_payload.summary }}
run: echo $MESSAGE
- env:
MESSAGE: ${{ github.event.client_payload.description }}
run: echo $MESSAGE
- name: 'Az CLI login'
uses: azure/login@v1
with:
client-id: '${{ secrets.AZAPPID }}'
tenant-id: '${{ secrets.AZTENTID }}'
subscription-id: '${{ secrets.AZSUBID }}'
- name: 'JIRA Create'
run: |
az keyvault secret show --vault-name wldemokv --name jiraapitoken -o json | jq -r .value > jiraapitoken
# Create in Hosted Atlassian
cat >jiraJSON <<EOT
{
"fields": {
"description": {
"content": [
{
"content": [
{
"text": "${{ github.event.client_payload.description }} :: Requested by ${{ github.event.client_payload.userid }}",
"type": "text"
}
],
"type": "paragraph"
}
],
"type": "doc",
"version": 1
},
"issuetype": {
"id": "10001"
},
"labels": [
"UserAsk"
],
"project": {
"id": "10000"
},
"summary": "${{ github.event.client_payload.summary }}"
},
"update": {}
}
EOT
curl --request POST --url "https://freshbrewed.atlassian.net/rest/api/3/issue" -u 'isaac@freshbrewed.science':"`cat jiraapitoken | tr -d '\n'`" --header 'Accept: application/json' --header 'Content-Type: application/json' -d @jiraJSON
- name: 'Plane.so Create'
run: |
az keyvault secret show --vault-name wldemokv --name planesotoken -o json | jq -r .value > planesotoken
# Create in Hosted Atlassian
cat >planeJSON <<EOT
{
"estimate_point": null,
"name": "${{ github.event.client_payload.summary }}",
"description_html": "<p>${{ github.event.client_payload.description }} :: Requested by ${{ github.event.client_payload.userid }}</p>",
"description_stripped": "${{ github.event.client_payload.description }} :: Requested by ${{ github.event.client_payload.userid }}",
"priority": "none",
"is_draft": false,
"labels": [
"93fcb710-94bf-4e8c-b419-9e6dfbee660f"
]
}
EOT
curl --request POST --url "https://api.plane.so/api/v1/workspaces/tpk/projects/9ca799e6-52c4-4a9e-8b40-461eef4f57e9/issues/" -H "X-API-Key: `cat planesotoken | tr -d '\n'`" -H 'Content-Type: application/json' --header 'Accept: application/json' -d @planeJSON
- name: 'Check AKV'
run: |
az keyvault secret show --vault-name wldemokv --name sessmtppass -o json | jq -r .value > sessmtppass
az keyvault secret show --vault-name wldemokv --name sessmtpuser -o json | jq -r .value > sessmtpuser
sudo apt-get update
sudo apt-get install -y s-nail || true
cat >rawDescription <<EOOOOL
${{ github.event.client_payload.description }}
EOOOOL
cat >rawSummary <<EOOOOT
${{ github.event.client_payload.summary }}
EOOOOT
set -x
cat rawSummary |sed ':a;N;$!ba;s/\n/ /g' | sed 's/"/\\"/g' > emailSummary
data="$( jq -nc --arg title "${{ github.event.client_payload.summary }}" --arg body "${{ github.event.client_payload.description }} :: Requested by ${{ github.event.client_payload.userid }}" '$ARGS.named')"
cat >emailJson2.json <<EOTT
$data
EOTT
# debug
echo "DEBUG:"
cat ./emailJson2.json
curl -X POST -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer `az keyvault secret show --vault-name wldemokv --name My90DayGHIssueWriter -o json | jq -r .value | tr -d '\n'`" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/idjohnson/jekyll-blog/issues -d @emailJson2.json > gh.o.json
export USERTLD=`echo "${{ github.event.client_payload.userid }}" | sed 's/^.*@//'`
export GHURL=`cat gh.o.json | jq -r .html_url`
# Slack Notification
slackdata="$( jq -nc --arg text "Feature Request $GHURL: ${{ github.event.client_payload.summary }} Requested by ${{ github.event.client_payload.userid }}" '$ARGS.named')"
cat >slackjson.json <<EOTT
$slackdata
EOTT
curl -X POST -H 'Content-type: application/json' `az keyvault secret show --vault-name wldemokv --name slackbuildswh -o json | jq -r .value | tr -d '\n'` -d @slackjson.json
# Discord
discorddata="$( jq -nc --arg content "Feature Request $GHURL: ${{ github.event.client_payload.summary }} Requested by ${{ github.event.client_payload.userid }}" '$ARGS.named')"
cat >discorddata.json <<EOTT
$discorddata
EOTT
curl -X POST -H "Content-Type:application/json" -d @discorddata.json `az keyvault secret show --vault-name wldemokv --name discordwhurlgeneral -o json | jq -r .value | tr -d '\n'`
# Keybase
keybasedata="$( jq -nc --arg msg "Feature Request $GHURL: ${{ github.event.client_payload.summary }} Requested by ${{ github.event.client_payload.userid }}" '$ARGS.named')"
cat >keybasedata.json <<EOTT
$keybasedata
EOTT
curl -X POST -H "Content-Type:application/json" -d @keybasedata.json `az keyvault secret show --vault-name wldemokv --name keybasebottpk -o json | jq -r .value | tr -d '\n'`
# Now Send Email
if [[ "$USERTLD" == "dontemailme.com" ]]; then
# do not CC user
echo "<h1>New Feature Requested</h1><p>user ${{ github.event.client_payload.userid }} has requested "`cat emailSummary`"</p><p>$GHURL</p><br/><br/>Kind Regards,<br/>Isaac Johnson" | s-nail -s "Blog: Feature $WIID Requested" -M "text/html" -S smtp=email-smtp.us-east-1.amazonaws.com:587 -S smtp-use-starttls -S ssl-verify=ignore -S smtp-auth=login -S smtp-auth-user=`cat sessmtpuser` -S smtp-auth-password=`cat sessmtppass` -c isaac.johnson@gmail.com -r isaac@freshbrewed.science isaac.johnson@gmail.com
else
# may not work
echo "<h1>New Feature Requested</h1><p>user ${{ github.event.client_payload.userid }} has requested "`cat emailSummary`"</p><p>$GHURL</p><br/><br/>Kind Regards,<br/>Isaac Johnson" | s-nail -s "Blog: Feature $WIID Requested" -M "text/html" -S smtp=email-smtp.us-east-1.amazonaws.com:587 -S smtp-use-starttls -S ssl-verify=ignore -S smtp-auth=login -S smtp-auth-user=`cat sessmtpuser` -S smtp-auth-password=`cat sessmtppass` -c ${{ github.event.client_payload.userid }} -r isaac@freshbrewed.science isaac.johnson@gmail.com
fi
# Teams
export SUMMARY="`jq -nc --arg text "${{ github.event.client_payload.summary }}" '$ARGS.named' | jq -r .text | sed 's/[^[:alnum:]_-]/ /g'`"
export DESCRIPTION="`jq -nc --arg text "${{ github.event.client_payload.description }}" '$ARGS.named' | jq -r .text | sed 's/[^[:alnum:]_-]/ /g'`"
cat > ./post.json <<endmsg
{
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"summary": "New Feedback Form",
"themeColor": "0078D7",
"sections": [
{
"activityImage": "https://ca.slack-edge.com/T4AQPQN8M-U4AL2JFC3-g45c8854734a-48",
"activityTitle": "Feedback Form Submission",
"activitySubtitle": "New Issue",
"facts": [
{
"name": "Requestor:",
"value": "${{ github.event.client_payload.userid }}"
},
{
"name": "Summary:",
"value": "$SUMMARY"
}
],
"text": "$GHURL - $DESCRIPTION",
"potentialAction": [
{
"@type": "OpenUri",
"name": "View conversation"
}
]
}
]
}
endmsg
curl -X POST -H "Content-Type: application/json" -d @post.json `az keyvault secret show --vault-name wldemokv --name msteamsgeneralfeedbackform -o json | jq -r .value | tr -d '\n'`
- name: Build count
uses: masci/datadog@v1
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
metrics: |
- type: "count"
name: "prfinal.runs.count"
value: 1.0
host: ${{ github.repository_owner }}
tags:
- "project:${{ github.repository }}"
- "branch:${{ github.head_ref }}"
- name: Datadog-Pass
uses: masci/datadog@v1
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
events: |
- title: "Passed building Feedback"
text: "Branch ${{ github.head_ref }} passed build"
alert_type: "info"
host: ${{ github.repository_owner }}
tags:
- "project:${{ github.repository }}"
- name: Turn off build light
run: |
curl -s -o /dev/null "https://kasarest.freshbrewed.science/off?devip=192.168.1.3&apikey=${{ secrets.KASAAPIKEY }}"
run_if_failure:
runs-on: ubuntu-latest
needs: run_if_payload
if: always() && (needs.run_if_payload.result == 'failure')
steps:
- name: Datadog-Fail
uses: masci/datadog@v1
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
events: |
- title: "Failed building Feedback"
text: "Branch ${{ github.head_ref }} failed to build"
alert_type: "error"
host: ${{ github.repository_owner }}
tags:
- "project:${{ github.repository }}"
- name: Fail count
uses: masci/datadog@v1
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
metrics: |
- type: "count"
name: "prfinal.fails.count"
value: 1.0
host: ${{ github.repository_owner }}
tags:
- "project:${{ github.repository }}"
- "branch:${{ github.head_ref }}"
- name: 'Az CLI login'
uses: azure/login@v1
with:
client-id: '${{ secrets.AZAPPID }}'
tenant-id: '${{ secrets.AZTENTID }}'
subscription-id: '${{ secrets.AZSUBID }}'
- run: |
# Email
az keyvault secret show --vault-name wldemokv --name sessmtppass -o json | jq -r .value > sessmtppass
az keyvault secret show --vault-name wldemokv --name sessmtpuser -o json | jq -r .value > sessmtpuser
sudo apt-get update
sudo apt-get install -y s-nail || true
export USERTLD=`echo "${{ github.event.client_payload.userid }}" | sed 's/^.*@//'`
echo "<h1>New Feature Requested</h1><p>user ${{ github.event.client_payload.userid }} but the formatting must have failed. Please check the pipeline: Run ID $GITHUB_RUN_ID!" | s-nail -s "Blog: Feature Requested (FAIL processing)" -M "text/html" -S smtp=email-smtp.us-east-1.amazonaws.com:587 -S smtp-use-starttls -S ssl-verify=ignore -S smtp-auth=login -S smtp-auth-user=`cat sessmtpuser` -S smtp-auth-password=`cat sessmtppass` -c isaac.johnson@gmail.com -r isaac@freshbrewed.science isaac.johnson@gmail.com
# Slack Notification
slackdata="$( jq -nc --arg text "Feature Request Issue Create Failure: see $GITHUB_JOB on Run $GITHUB_RUN_ID :: requested by ${{ github.event.client_payload.userid }}" '$ARGS.named')"
cat >slackjson.json <<EOTT
$slackdata
EOTT
curl -X POST -H 'Content-type: application/json' `az keyvault secret show --vault-name wldemokv --name slackbuildswh -o json | jq -r .value | tr -d '\n'` -d @slackjson.json
# Discord Notification
discorddata="$( jq -nc --arg content "Feature Request Issue Create Failure: ${{ github.event.client_payload.summary }} Requested by ${{ github.event.client_payload.userid }}" '$ARGS.named')"
cat >discorddata.json <<EOTT
$discorddata
EOTT
curl -X POST -H "Content-Type:application/json" -d @discorddata.json `az keyvault secret show --vault-name wldemokv --name discordwhurlgeneral -o json | jq -r .value | tr -d '\n'`
# Keybase
keybasedata="$( jq -nc --arg msg "Feature Request Issue Create Failure: ${{ github.event.client_payload.summary }} Requested by ${{ github.event.client_payload.userid }}" '$ARGS.named')"
cat >keybasedata.json <<EOTT
$keybasedata
EOTT
curl -X POST -H "Content-Type:application/json" -d @keybasedata.json `az keyvault secret show --vault-name wldemokv --name keybasebottpk -o json | jq -r .value | tr -d '\n'`
# Teams
export SUMMARY="`jq -nc --arg text "${{ github.event.client_payload.summary }}" '$ARGS.named' | jq -r .text | sed 's/[^[:alnum:]_-]/ /g'`"
export DESCRIPTION="`jq -nc --arg text "${{ github.event.client_payload.description }}" '$ARGS.named' | jq -r .text | sed 's/[^[:alnum:]_-]/ /g'`"
cat > ./post.json <<endmsg
{
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"summary": "New Feedback Form (error)",
"themeColor": "0078D7",
"sections": [
{
"activityImage": "https://ca.slack-edge.com/T4AQPQN8M-U4AL2JFC3-g45c8854734a-48",
"activityTitle": "Feedback Form Submission (error)",
"activitySubtitle": "New Issue",
"facts": [
{
"name": "Requestor:",
"value": "${{ github.event.client_payload.userid }}"
},
{
"name": "Summary:",
"value": "$SUMMARY"
}
],
"text": "$DESCRIPTION",
"potentialAction": [
{
"@type": "OpenUri",
"name": "View conversation"
}
]
}
]
}
endmsg
curl -X POST -H "Content-Type: application/json" -d @post.json `az keyvault secret show --vault-name wldemokv --name msteamsgeneralfeedbackform -o json | jq -r .value | tr -d '\n'`
- env:
MESSAGE: ${{ github.event.client_payload.message }}
run: echo $MESSAGE