-
-
Notifications
You must be signed in to change notification settings - Fork 0
377 lines (358 loc) · 16.9 KB
/
ci.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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
name: CI/CD
on:
workflow_dispatch:
inputs:
tag:
description: override release tag
required: false
push:
branches:
- main
- canary
- experimental
env:
CI: true
# NX_CLOUD_DISTRIBUTED_EXECUTION: true # this enables DTE
# NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT: 3 # expected number of agents
# NX_BRANCH: ${{ github.event.number || github.ref_name }}
# NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
STORM_BOT: Stormie-Bot
STORM_REPOSITORY: ${{ github.repositoryUrl }}
STORM_WORKSPACE_ROOT: ${{ github.workspace }}
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.STORM_BOT_NPM_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.STORM_BOT_CARGO_TOKEN }}
jobs:
start:
name: Started CI workflow
if: github.repository == 'storm-software/storm-stack' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/canary' || github.ref == 'refs/heads/experimental')
runs-on: ubuntu-latest
steps:
- name: Send Slack notification - Deployment started
uses: slackapi/[email protected]
with:
channel-id: "notifications"
payload: |
{
"text": "Deployment for ${{ github.repository }} has started (In Progress)",
"attachments": [
{
"pretext": "Deployment for ${{ github.repository }} has started",
"color": "1fb2a6",
"fields": [
{
"title": "Status",
"short": true,
"value": "In Progress"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.STORM_BOT_SLACK_TOKEN }}
- name: Send Discord notification - Deployment started
uses: Ilshidur/action-discord@master
with:
args: "Deployment for ${{ github.repository }} has started - #${{
github.run_number }}"
env:
DISCORD_WEBHOOK: ${{ secrets.STORM_BOT_DISCORD_WEBHOOK }}
DISCORD_USERNAME: ${{ env.STORM_BOT }}
DISCORD_AVATAR: "https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-stormie.png"
DISCORD_EMBEDS:
'[{"title": "Deployment #${{ github.run_number }} has started",
"description": "Deployment for ${{ github.repository }} is currently
in process - #${{ github.run_number }}", "thumbnail": { "url":
"https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-fill.png"
}, "image": { "url":
"https://pub-761b436209f44a4d886487c917806c08.r2.dev/logo-fill.png"
}, "author": { "name": "${{ github.actor }}", "url":
"https://github.com/${{ github.actor }}", "icon_url":
"https://avatars.githubusercontent.com/u/${{ github.actor_id }}?v=4"
}, "fields": [ { "name": "Repository", "value": "${{
github.repository }}" }, { "name": "Repository URL", "value": "${{
github.repositoryUrl }}" }, { "name": "Pipeline Status", "value":
"In Progress" }], "color": 2077350, "timestamp": "${{
github.event.repository.updated_at }}", "url": "${{
github.event.pull_request.html_url || github.event.head_commit.url
}}", "footer": { "text": "Click here to see the full workflow
details: ${{ github.event.pull_request.html_url ||
github.event.head_commit.url }}", "icon_url":
"https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-fill.png"
} }]'
- name: Send Telegram notification - Deployment started
uses: storm-software/action-telegram-notify@main
with:
status: "in-progress"
env:
TELEGRAM_TOKEN: ${{ secrets.STORM_BOT_TELEGRAM_TOKEN }}
TELEGRAM_CHAT: ${{ secrets.STORM_BOT_TELEGRAM_NOTIFICATION_CHAT }}
release:
name: Continuous Integration
if: always() && !cancelled() && !contains(needs.*.result, 'failure') && github.event.pull_request.draft == false
needs:
- start
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
actions: read
contents: write
id-token: write
steps:
- name: Checkout [Pull Request]
uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request' }}
with:
# By default, PRs will be checked-out based on the Merge Commit, but we want the actual branch HEAD.
ref: ${{ github.event.pull_request.head.sha }}
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
token: ${{ secrets.STORM_BOT_GITHUB_TOKEN }}
- name: Checkout `main` branch
uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request' }}
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
token: ${{ secrets.STORM_BOT_GITHUB_TOKEN }}
- name: Setup workspace
uses: storm-software/action-setup@main
with:
package-manager-version: 9.12.1
storm-bot-github-token: ${{ secrets.STORM_BOT_GITHUB_TOKEN }}
- name: Run Nx Set SHAs
uses: nrwl/nx-set-shas@v4
with:
main-branch-name: main
- name: Run build script
run: pnpm build-all
shell: bash
- name: Release Library Version Updates
run: pnpm release --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }}
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.STORM_BOT_NPM_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.STORM_BOT_CARGO_TOKEN }}
STORM_BOT: Stormie-Bot
STORM_WORKSPACE_ROOT: ${{ github.workspace }}
STORM_REPOSITORY: ${{ github.repositoryUrl }}
TAG: ${{ inputs.tag }}
success:
needs:
- release
if: ${{ success() }}
name: Send success notification
runs-on: ubuntu-latest
steps:
- name: Send Slack notification - Deployment successful
uses: slackapi/[email protected]
with:
channel-id: "notifications"
update-ts: ${{ steps.release.outputs.ts }}
payload: |
{
"text": "Deployment for ${{ github.repository }} has finished (Completed) \n\nPipeline Status: Success \nClick here to see the full workflow details: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
"attachments": [
{
"pretext": "Deployment for ${{ github.repository }} has finished successfully",
"color": "087f5b",
"fields": [
{
"title": "Status",
"short": true,
"value": "Completed"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.STORM_BOT_SLACK_TOKEN }}
- name: Send Discord notification - Deployment successful
uses: Ilshidur/action-discord@master
with:
args: "Deployment for ${{ github.repository }} finished successfully -
#${{ github.run_number }}"
env:
DISCORD_WEBHOOK: ${{ secrets.STORM_BOT_DISCORD_WEBHOOK }}
DISCORD_USERNAME: ${{ env.STORM_BOT }}
DISCORD_AVATAR: "https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-stormie.png"
DISCORD_EMBEDS:
'[{"title": "Deployment #${{ github.run_number }} was successful!",
"description": "Deployment for ${{ github.repository }} has finished
successfully - #${{ github.run_number }}", "thumbnail": { "url":
"https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-fill.png"
}, "image": { "url":
"https://pub-761b436209f44a4d886487c917806c08.r2.dev/logo-fill.png"
}, "author": { "name": "${{ github.actor }}", "url":
"https://github.com/${{ github.actor }}", "icon_url":
"https://avatars.githubusercontent.com/u/${{ github.actor_id }}?v=4"
}, "fields": [ { "name": "Repository", "value": "${{
github.repository }}" }, { "name": "Repository URL", "value": "${{
github.repositoryUrl }}" }, { "name": "Pipeline Status", "value":
"Success" }], "color": 556891, "timestamp": "${{
github.event.repository.updated_at }}", "url": "${{
github.event.pull_request.html_url || github.event.head_commit.url
}}", "footer": { "text": "Click here to see the full workflow
details: ${{ github.event.pull_request.html_url ||
github.event.head_commit.url }}", "icon_url":
"https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-fill.png"
}}]'
- name: Send Telegram notification - Deployment successful
uses: storm-software/action-telegram-notify@main
with:
status: "success"
env:
TELEGRAM_TOKEN: ${{ secrets.STORM_BOT_TELEGRAM_TOKEN }}
TELEGRAM_CHAT: ${{ secrets.STORM_BOT_TELEGRAM_NOTIFICATION_CHAT }}
failure:
needs:
- release
if: ${{ failure() }}
name: Send failure notification
runs-on: ubuntu-latest
steps:
- name: Send Slack notification - Deployment failed
uses: slackapi/[email protected]
with:
channel-id: "notifications"
update-ts: ${{ steps.release.outputs.ts }}
payload: |
{
"text": "Deployment for ${{ github.repository }} has finished (Failure) \n\nPipeline Status: Failure\nError: ${{ job.conclusion }}\nReason: ${{ job.cancelled }}\nConclusion: ${{ job.conclusion }}\nOutput: ${{ job.output }}\nLogs: ${{ job.logs }} \nSteps: ${{ job.steps }} \nActions: ${{ job.actions }} \nServices: ${{ job.services }} \nEnvironment: ${{ job.environment}} \nClick here to see the full workflow details: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
"attachments": [
{
"pretext": "Deployment for ${{ github.repository }} has finished with failures",
"color": "990000",
"fields": [
{
"title": "Status",
"short": true,
"value": "Failure"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.STORM_BOT_SLACK_TOKEN }}
- name: Send Discord notification - Deployment failed
uses: Ilshidur/action-discord@master
with:
args:
"Deployment for ${{ github.repository }} finished with failures -
#${{ github.run_number }}"
env:
DISCORD_WEBHOOK: ${{ secrets.STORM_BOT_DISCORD_WEBHOOK }}
DISCORD_USERNAME: ${{ env.STORM_BOT }}
DISCORD_AVATAR: "https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-stormie.png"
DISCORD_EMBEDS:
'[{"title": "Deployment #${{ github.run_number }} has failed",
"description": "Deployment for ${{ github.repository }} finished
with failures - #${{ github.run_number }}", "thumbnail": { "url":
"https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-fill.png"
}, "image": { "url":
"https://pub-761b436209f44a4d886487c917806c08.r2.dev/logo-fill.png"
}, "author": { "name": "${{ github.actor }}", "url":
"https://github.com/${{ github.actor }}", "icon_url":
"https://avatars.githubusercontent.com/u/${{ github.actor_id }}?v=4"
}, "fields": [ { "name": "Repository", "value": "${{
github.repository }}" }, { "name": "Repository URL", "value": "${{
github.repositoryUrl }}" }, { "name": "Pipeline Status", "value":
"Failure" }, { "name": "Event", "value": "${{ github.event_name }}"
}, { "name": "Result", "value": "${{ steps.release.result }}" }, {
"name": "Conclusion", "value": "${{ steps.release.conclusion }}" },
{ "name": "Output", "value": "${{ toJSON(steps.release.outputs) }}"
}], "color": 10027008, "timestamp": "${{
github.event.repository.updated_at }}", "url": "${{
github.event.pull_request.html_url || github.event.head_commit.url
}}", "footer": { "text": "Click here to see the full workflow
details: ${{ github.event.pull_request.html_url ||
github.event.head_commit.url }}", "icon_url":
"https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-fill.png"
} }]'
- name: Send Telegram notification - Deployment failed
uses: storm-software/action-telegram-notify@main
with:
status: "failed"
env:
TELEGRAM_TOKEN: ${{ secrets.STORM_BOT_TELEGRAM_TOKEN }}
TELEGRAM_CHAT: ${{ secrets.STORM_BOT_TELEGRAM_NOTIFICATION_CHAT }}
cancelled:
needs:
- release
if: ${{ cancelled() }}
name: Send cancelled notification
runs-on: ubuntu-latest
steps:
- name: Send Slack notification - Deployment cancelled
uses: slackapi/[email protected]
with:
channel-id: "notifications"
update-ts: ${{ steps.release.outputs.ts }}
payload: |
{
"text": "Deployment for ${{ github.repository }} has finished (Cancelled) \n\nPipeline Status: Cancelled\nError: ${{ job.conclusion }}\nReason: ${{ job.cancelled }}\nConclusion: ${{ job.conclusion }}\nOutput: ${{ job.output }}\nLogs: ${{ job.logs }} \nSteps: ${{ job.steps }} \nActions: ${{ job.actions }} \nServices: ${{ job.services }} \nEnvironment: ${{ job.environment}} \nClick here to see the full workflow details: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
"attachments": [
{
"pretext": "Deployment for ${{ github.repository }} has been cancelled",
"color": "990000",
"fields": [
{
"title": "Status",
"short": true,
"value": "Cancelled"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.STORM_BOT_SLACK_TOKEN }}
- name: Send Discord notification - Deployment cancelled
uses: Ilshidur/action-discord@master
with:
args:
"Deployment for ${{ github.repository }} has been cancelled - #${{
github.run_number }}"
env:
DISCORD_WEBHOOK: ${{ secrets.STORM_BOT_DISCORD_WEBHOOK }}
DISCORD_USERNAME: ${{ env.STORM_BOT }}
DISCORD_AVATAR: "https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-stormie.png"
DISCORD_EMBEDS:
'[{"title": "Deployment #${{ github.run_number }} was cancelled",
"description": "Deployment for ${{ github.repository }} was
cancelled before it could complete normal execution - #${{
github.run_number }}", "thumbnail": { "url":
"https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-fill.png"
}, "image": { "url":
"https://pub-761b436209f44a4d886487c917806c08.r2.dev/logo-fill.png"
}, "author": { "name": "${{ github.actor }}", "url":
"https://github.com/${{ github.actor }}", "icon_url":
"https://avatars.githubusercontent.com/u/${{ github.actor_id }}?v=4"
}, "fields": [ { "name": "Repository", "value": "${{
github.repository }}" }, { "name": "Repository URL", "value": "${{
github.repositoryUrl }}" }, { "name": "Pipeline Status", "value":
"Cancelled" }, { "name": "Event", "value": "${{ github.event_name
}}" }, { "name": "Result", "value": "${{ steps.release.result }}" },
{ "name": "Conclusion", "value": "${{ steps.release.conclusion }}"
}, { "name": "Output", "value": "${{ toJSON(steps.release.outputs)
}}" }], "color": 16565273, "timestamp": "${{
github.event.repository.updated_at }}", "url": "${{
github.event.pull_request.html_url || github.event.head_commit.url
}}", "footer": { "text": "Click here to see the full workflow
details: ${{ github.event.pull_request.html_url ||
github.event.head_commit.url }}", "icon_url":
"https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-fill.png"
} }]'
- name: Send Telegram notification - Deployment cancelled
uses: storm-software/action-telegram-notify@main
with:
status: "cancelled"
env:
TELEGRAM_TOKEN: ${{ secrets.STORM_BOT_TELEGRAM_TOKEN }}
TELEGRAM_CHAT: ${{ secrets.STORM_BOT_TELEGRAM_NOTIFICATION_CHAT }}