-
Notifications
You must be signed in to change notification settings - Fork 11
588 lines (587 loc) · 26.2 KB
/
CICD.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
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# SPDX-License-Identifier: ice License 1.0
name: CI/CD
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
verify-licensing:
name: Verify Licensing
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find latest Go Version
id: findLatestGoVersion
run: |
LATEST_GO_VERSION=$(make latestGoVersion)
echo "::set-output name=latestGoVersion::$LATEST_GO_VERSION"
- name: Setup GO
uses: actions/setup-go@v5
with:
go-version: ${{ steps.findLatestGoVersion.outputs.latestGoVersion }}
- name: Check License
run: make checkLicense
- name: Slack Notification For Failure/Cancellation
if: ${{ github.event_name == 'push' && (failure() || cancelled()) }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Failed> ${{ job.status }}
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':sob:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
https://github.com/ice-blockchain/${{ github.event.repository.name }}
verify-latest-versions-used:
name: Verify Latest Versions
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find latest Go Version
id: findLatestGoVersion
run: |
LATEST_GO_VERSION=$(make latestGoVersion)
echo "::set-output name=latestGoVersion::$LATEST_GO_VERSION"
- name: Setup GO
uses: actions/setup-go@v5
with:
go-version: ${{ steps.findLatestGoVersion.outputs.latestGoVersion }}
- name: Check If We're Up to Date with Everything
run: make checkModVersion checkIfAllDependenciesAreUpToDate
- name: Slack Notification For Failure/Cancellation
if: ${{ github.event_name == 'push' && (failure() || cancelled()) }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Failed> ${{ job.status }}
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':sob:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
https://github.com/ice-blockchain/${{ github.event.repository.name }}
verify-auto-generated:
name: Verify Auto Generated
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find latest Go Version
id: findLatestGoVersion
run: |
LATEST_GO_VERSION=$(make latestGoVersion)
echo "::set-output name=latestGoVersion::$LATEST_GO_VERSION"
- name: Setup GO
uses: actions/setup-go@v5
with:
go-version: ${{ steps.findLatestGoVersion.outputs.latestGoVersion }}
- name: Check Auto Generated Files
run: make checkGenerated
- name: Slack Notification For Failure/Cancellation
if: ${{ github.event_name == 'push' && (failure() || cancelled()) }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Failed> ${{ job.status }}
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':sob:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
https://github.com/ice-blockchain/${{ github.event.repository.name }}
lint:
name: Lint
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find latest Go Version
id: findLatestGoVersion
run: |
LATEST_GO_VERSION=$(make latestGoVersion)
echo "::set-output name=latestGoVersion::$LATEST_GO_VERSION"
- name: Setup GO
uses: actions/setup-go@v5
with:
go-version: ${{ steps.findLatestGoVersion.outputs.latestGoVersion }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
- name: Slack Notification For Failure/Cancellation
if: ${{ github.event_name == 'push' && (failure() || cancelled()) }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Failed> ${{ job.status }}
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':sob:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
https://github.com/ice-blockchain/${{ github.event.repository.name }}
build:
name: Build
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find latest Go Version
id: findLatestGoVersion
run: |
LATEST_GO_VERSION=$(make latestGoVersion)
echo "::set-output name=latestGoVersion::$LATEST_GO_VERSION"
- name: Setup GO
uses: actions/setup-go@v5
with:
go-version: ${{ steps.findLatestGoVersion.outputs.latestGoVersion }}
- name: Build all
run: make build-all@ci/cd
- name: Slack Notification For Failure/Cancellation
if: ${{ github.event_name == 'push' && (failure() || cancelled()) }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Failed> ${{ job.status }}
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':sob:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
https://github.com/ice-blockchain/${{ github.event.repository.name }}
test:
name: Test
strategy:
matrix:
package: [ "miner", "coin-distribution", "extra-bonus-notifier", "tokenomics", "cmd/freezer", "cmd/freezer-refrigerant", "cmd/freezer-miner", "cmd/freezer-coin-distributer"]
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || github.event_name == 'push' }}
runs-on: ubuntu-latest
# runs-on: self-hosted-ubuntu-latest-x64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find latest Go Version
id: findLatestGoVersion
run: |
LATEST_GO_VERSION=$(make latestGoVersion)
echo "::set-output name=latestGoVersion::$LATEST_GO_VERSION"
- name: Setup GO
uses: actions/setup-go@v5
with:
go-version: ${{ steps.findLatestGoVersion.outputs.latestGoVersion }}
- name: Test ${{ matrix.package }}
env:
SMS_CLIENT_USER: ${{ secrets.SMS_CLIENT_USER }}
SMS_CLIENT_PASSWORD: ${{ secrets.SMS_CLIENT_PASSWORD }}
EMAIL_CLIENT_APIKEY: ${{ secrets.EMAIL_CLIENT_APIKEY }}
PICTURE_STORAGE_ACCESS_KEY: ${{ secrets.PICTURE_STORAGE_ACCESS_KEY }}
INAPP_NOTIFICATIONS_CLIENT_KEY: ${{ secrets.INAPP_NOTIFICATIONS_CLIENT_KEY }}
INAPP_NOTIFICATIONS_CLIENT_SECRET: ${{ secrets.INAPP_NOTIFICATIONS_CLIENT_SECRET }}
INAPP_NOTIFICATIONS_CLIENT_APP_ID: ${{ secrets.INAPP_NOTIFICATIONS_CLIENT_APP_ID }}
TRANSLATIONS_CLIENT_APIKEY: ${{ secrets.TRANSLATIONS_CLIENT_APIKEY }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GCP_FIREBASE_AUTH_API_KEY: ${{ secrets.GCP_FIREBASE_AUTH_API_KEY }}
run: |
cd ${{ matrix.package }}
make -f ${{ github.workspace }}/Makefile test@ci/cd
make -f ${{ github.workspace }}/Makefile coverage
- name: Slack Notification For Failure/Cancellation
if: ${{ github.event_name == 'push' && (failure() || cancelled()) }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Failed> ${{ job.status }}
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':sob:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
freezer/${{ matrix.package }}
https://github.com/ice-blockchain/${{ github.event.repository.name }}
benchmark:
name: Benchmark
strategy:
matrix:
package: [ "miner", "coin-distribution", "extra-bonus-notifier", "tokenomics", "cmd/freezer", "cmd/freezer-refrigerant", "cmd/freezer-miner", "cmd/freezer-coin-distributer"]
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || github.event_name == 'push' }}
runs-on: ubuntu-latest
# runs-on: self-hosted-ubuntu-latest-x64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find latest Go Version
id: findLatestGoVersion
run: |
LATEST_GO_VERSION=$(make latestGoVersion)
echo "::set-output name=latestGoVersion::$LATEST_GO_VERSION"
- name: Setup GO
uses: actions/setup-go@v5
with:
go-version: ${{ steps.findLatestGoVersion.outputs.latestGoVersion }}
- name: Benchmark ${{ matrix.package }}
env:
SMS_CLIENT_USER: ${{ secrets.SMS_CLIENT_USER }}
SMS_CLIENT_PASSWORD: ${{ secrets.SMS_CLIENT_PASSWORD }}
EMAIL_CLIENT_APIKEY: ${{ secrets.EMAIL_CLIENT_APIKEY }}
PICTURE_STORAGE_ACCESS_KEY: ${{ secrets.PICTURE_STORAGE_ACCESS_KEY }}
INAPP_NOTIFICATIONS_CLIENT_KEY: ${{ secrets.INAPP_NOTIFICATIONS_CLIENT_KEY }}
INAPP_NOTIFICATIONS_CLIENT_SECRET: ${{ secrets.INAPP_NOTIFICATIONS_CLIENT_SECRET }}
INAPP_NOTIFICATIONS_CLIENT_APP_ID: ${{ secrets.INAPP_NOTIFICATIONS_CLIENT_APP_ID }}
TRANSLATIONS_CLIENT_APIKEY: ${{ secrets.TRANSLATIONS_CLIENT_APIKEY }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GCP_FIREBASE_AUTH_API_KEY: ${{ secrets.GCP_FIREBASE_AUTH_API_KEY }}
run: |
cd ${{ matrix.package }}
make -f ${{ github.workspace }}/Makefile benchmark@ci/cd
- name: Slack Notification For Failure/Cancellation
if: ${{ github.event_name == 'push' && (failure() || cancelled()) }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Failed> ${{ job.status }}
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':sob:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
freezer/${{ matrix.package }}
https://github.com/ice-blockchain/${{ github.event.repository.name }}
dockerfile:
name: Verify Dockerfile
strategy:
matrix:
service: [ "freezer", "freezer-refrigerant", "freezer-miner", "freezer-coin-distributer"]
#those are not supported by golang docker image: linux/riscv64
#platforms: linux/s390x,linux/arm64,linux/amd64,linux/ppc64le
#commented because build takes too damn much with the other 3 platforms (~10 mins for each!!!) and we don`t need them atm
platform: ["linux/amd64"]
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || github.event_name == 'push' }}
runs-on: ubuntu-latest
# runs-on: self-hosted-ubuntu-latest-x64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find latest Go Version
id: findLatestGoVersion
run: |
LATEST_GO_VERSION=$(make latestGoVersion)
echo "::set-output name=latestGoVersion::$LATEST_GO_VERSION"
- name: Setup GO
uses: actions/setup-go@v5
with:
go-version: ${{ steps.findLatestGoVersion.outputs.latestGoVersion }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- id: buildx
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
install: true
- name: Build Image Information
id: build-image-info
env:
PR_NUMBER: ${{ github.event.number }}
SERVICE_NAME: ${{ matrix.service }}
run: |
echo "::set-output name=tags::registry.digitalocean.com/ice-io/$SERVICE_NAME:pr$PR_NUMBER"
echo "::set-output name=dockerFileLocation::./cmd/$SERVICE_NAME/Dockerfile"
- name: Build ${{ matrix.platform }} ${{ matrix.service }} docker image
uses: docker/build-push-action@v3
with:
context: .
file: ${{ steps.build-image-info.outputs.dockerFileLocation }}
platforms: ${{ matrix.platform }}
push: false
build-args: |
SERVICE_NAME=${{ matrix.service }}
tags: ${{ steps.build-image-info.outputs.tags }}
- name: Slack Notification For Failure/Cancellation
if: ${{ github.event_name == 'push' && (failure() || cancelled()) }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Failed> ${{ job.status }}
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':sob:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
${{ matrix.service }}
PR:
needs: [verify-licensing, verify-latest-versions-used, verify-auto-generated, lint, build, test, benchmark, dockerfile]
name: PR
if: ${{ always() && (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checking if all previous jobs were successful
env:
ALL_SUCCESSFUL: ${{ contains(join(needs.*.result, ','), 'failure') == false && contains(join(needs.*.result, ','), 'cancelled') == false && contains(join(needs.*.result, ','), 'skipped') == false }}
run: |
if [ $ALL_SUCCESSFUL == 'true' ]
then
exit 0
else
exit 1
fi
- name: Slack Notification For Failure/Cancellation
if: ${{ github.event_name == 'push' && (failure() || cancelled()) }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Failed> ${{ job.status }}
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':sob:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
https://github.com/ice-blockchain/${{ github.event.repository.name }}
release:
needs: [PR]
name: Release
outputs:
nextTag: ${{ steps.check_tag.outputs.next_tag }}
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find latest Go Version
id: findLatestGoVersion
run: |
LATEST_GO_VERSION=$(make latestGoVersion)
echo "::set-output name=latestGoVersion::$LATEST_GO_VERSION"
- name: Setup GO
uses: actions/setup-go@v5
with:
go-version: ${{ steps.findLatestGoVersion.outputs.latestGoVersion }}
- name: Build Artefacts
run: env GOOS=linux env GOARCH=amd64 make buildAllBinaries
- name: Compute new Tag version
id: compute_tag
uses: craig-day/compute-tag@v14
with:
github_token: ${{ github.token }}
version_type: minor
- id: check_tag
name: Check new computed Tag version
run: |
NEW_TAG_VERSION=$(echo "$NEW_TAG_VERSION" | sed 's/.\{2\}$//')
if [ $NEW_TAG_VERSION == 'v1.0.0' ]
then
echo "::set-output name=next_tag::$NEW_TAG_VERSION"
else
echo "::set-output name=next_tag::${NEW_TAG_VERSION}.0"
fi
env:
NEW_TAG_VERSION: ${{ steps.compute_tag.outputs.next_tag }}
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.check_tag.outputs.next_tag }}
draft: false
prerelease: false
fail_on_unmatched_files: true
make_latest: true
files: |
freezer.linux.amd64.bin
freezer-refrigerant.linux.amd64.bin
freezer-miner.linux.amd64.bin
freezer-coin-distributer.linux.amd64.bin
- name: Slack Notification For Failure/Cancellation
if: ${{ github.event_name == 'push' && (failure() || cancelled()) }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Failed> ${{ job.status }}
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':sob:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
https://github.com/ice-blockchain/${{ github.event.repository.name }}
push_docker:
needs: [ release ]
name: Push Docker
strategy:
matrix:
service: [ "freezer", "freezer-refrigerant", "freezer-miner", "freezer-coin-distributer"]
#those are not supported by golang docker image: linux/riscv64
#platforms: linux/s390x,linux/arm64,linux/amd64,linux/ppc64le
#commented because build takes too damn much with the other 3 platforms (~10 mins for each!!!) and we don`t need them atm
platform: ["linux/amd64"]
outputs:
nextTag: ${{ steps.build-image-info.outputs.nextTag }}
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
# runs-on: self-hosted-ubuntu-latest-x64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find latest Go Version
id: findLatestGoVersion
run: |
LATEST_GO_VERSION=$(make latestGoVersion)
echo "::set-output name=latestGoVersion::$LATEST_GO_VERSION"
- name: Setup GO
uses: actions/setup-go@v5
with:
go-version: ${{ steps.findLatestGoVersion.outputs.latestGoVersion }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- id: buildx
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
install: true
- name: Login to Digital Ocean Container Registry
uses: docker/login-action@v2
with:
registry: registry.digitalocean.com
username: ${{ secrets.DO_CONTAINER_REGISTRY_TOKEN }}
password: ${{ secrets.DO_CONTAINER_REGISTRY_TOKEN }}
- name: Build Image Information
id: build-image-info
env:
VERSION: ${{needs.release.outputs.nextTag}}
SERVICE_NAME: ${{ matrix.service }}
run: |
LATEST_TAG=registry.digitalocean.com/ice-io/$SERVICE_NAME:latest
NEXT_VERSION_TAG=registry.digitalocean.com/ice-io/$SERVICE_NAME:$VERSION
echo "::set-output name=nextTag::$VERSION"
echo "::set-output name=tags::${LATEST_TAG},${NEXT_VERSION_TAG}"
echo "::set-output name=dockerFileLocation::./cmd/$SERVICE_NAME/Dockerfile"
- name: Build ${{ matrix.platform }} ${{ matrix.service }} docker image
uses: docker/build-push-action@v3
with:
context: .
file: ${{ steps.build-image-info.outputs.dockerFileLocation }}
platforms: ${{ matrix.platform }}
push: true
build-args: |
SERVICE_NAME=${{ matrix.service }}
tags: ${{ steps.build-image-info.outputs.tags }}
- name: Slack Notification For Failure/Cancellation
if: ${{ github.event_name == 'push' && (failure() || cancelled()) }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Failed> ${{ job.status }}
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':sob:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
${{ matrix.platform }} ${{ matrix.service }}
trigger_deployment:
needs: [ push_docker ]
name: Trigger Deployment
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Setting ENV variables for deployment
run: |
echo "APP_TAG=${{needs.push_docker.outputs.nextTag}}" >> $GITHUB_ENV
- name: Checkout the target `master` branch of `secret-infrastructure`
uses: actions/checkout@v4
with:
repository: ice-blockchain/secret-infrastructure
ref: master
token: ${{ secrets.ICE_CI_CD_BOT_GH_PAT }}
path: secret-infrastructure
fetch-depth: 0
- name: Update [staging] application tag version in helm/freezer/staging/common-values.yaml
uses: mikefarah/yq@master
with:
cmd: |
cd secret-infrastructure
yq e -i '.generic-service-chart.applicationImage.tag = strenv(APP_TAG)' helm/freezer/staging/common-values.yaml
- name: Update [staging] application tag version in helm/freezer-refrigerant/staging/common-values.yaml
uses: mikefarah/yq@master
with:
cmd: |
cd secret-infrastructure
yq e -i '.generic-service-chart.applicationImage.tag = strenv(APP_TAG)' helm/freezer-refrigerant/staging/common-values.yaml
- name: Update [staging] application tag version in helm/freezer-miner/staging/common-values.yaml
uses: mikefarah/yq@master
with:
cmd: |
cd secret-infrastructure
yq e -i '.generic-service-chart.applicationImage.tag = strenv(APP_TAG)' helm/freezer-miner/staging/common-values.yaml
- name: Update [staging] application tag version in helm/freezer-coin-distributer/staging/common-values.yaml
uses: mikefarah/yq@master
with:
cmd: |
cd secret-infrastructure
yq e -i '.generic-service-chart.applicationImage.tag = strenv(APP_TAG)' helm/freezer-coin-distributer/staging/common-values.yaml
- name: Commit and Push Changes to Application Tag Version
run: |
cd secret-infrastructure
git config user.name "ice CI/CD Bot"
git config user.email [email protected]
git add helm/freezer/staging/common-values.yaml
git add helm/freezer-refrigerant/staging/common-values.yaml
git add helm/freezer-miner/staging/common-values.yaml
git add helm/freezer-coin-distributer/staging/common-values.yaml
git commit -m "Updated 'freezer' & 'freezer-refrigerant' & 'freezer-miner' & 'freezer-coin-distributer' tag version (${{env.APP_TAG}}) in application helm chart deployment manifests"
git push --set-upstream origin master
- name: Slack Notification For Success
if: ${{ success() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Succeeded, Waiting for Deployment Status Notification...
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':rocket:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
https://staging.r.api.ice.io/tokenomics/r
https://staging.w.api.ice.io/tokenomics/w
- name: Slack Notification For Failure
if: ${{ github.event_name == 'push' && (failure() || cancelled()) }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.BACKEND_SLACK_WEBHOOK }}
SLACK_TITLE: CI Failed> ${{ job.status }}
SLACK_USERNAME: ${{ github.event.repository.name }}-ci-bot
SLACK_ICON: https://avatars.githubusercontent.com/u/102382658?s=400&u=62e73f4cb845c48a07a19e03c6f84b721e40c0a6&v=4
SLACK_ICON_EMOJI: ':sob:'
SLACK_COLOR: ${{ job.status }}
SLACK_FOOTER: |
https://staging.r.api.ice.io/tokenomics/r
https://staging.w.api.ice.io/tokenomics/w