-
Notifications
You must be signed in to change notification settings - Fork 0
475 lines (452 loc) · 18.2 KB
/
console-ci.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
name: Console CI/CD
on:
push:
paths-ignore:
- 'apps/dashboard/**'
- 'deploy/helm/dashboard/**'
- ".github/workflows/ci.yaml"
- 'apps/sandbox/**'
- 'deploy/helm/sandbox/**'
- ".github/workflows/sandbox-ci.yaml"
branches:
- main
pull_request:
paths-ignore:
- 'apps/dashboard/**'
- 'deploy/helm/dashboard/**'
- ".github/workflows/ci.yaml"
- 'apps/sandbox/**'
- 'deploy/helm/sandbox/**'
- ".github/workflows/sandbox-ci.yaml"
branches:
- main
release:
types:
- prereleased
- released
workflow_dispatch:
inputs:
ENVIRONMENT_NAME:
description: 'Environment Name'
required: true
default: enkinet
type: choice
options:
- enkinet
- hammunet
- gilganet
- mardunet
- dumunet
env:
active_network: 'stokenet'
prerelease_network: 'stokenet'
release_network: 'mainnet'
jenkins_job_name: 'kubernetes-deployments/job/dapps-console'
helm_dir: 'deploy/helm/console'
dev_eks_cluster: 'rdx-works-main-dev'
prod_eks_cluster: 'rtlj-prod'
permissions:
id-token: write
pull-requests: write
contents: read
deployments: write
packages: write
jobs:
trigger:
name: Check trigger
if: >
( github.event.action == 'prereleased' && contains( github.event.release.tag_name, 'console') ) ||
( github.event.action == 'released' && contains( github.event.release.tag_name, 'console') ) ||
( github.event_name == 'workflow_dispatch' ) ||
( github.ref == 'refs/heads/main' && github.event_name == 'push') ||
( github.event_name == 'pull_request' )
runs-on: ubuntu-latest
steps:
- name: Dump context
uses: RDXWorks-actions/ghaction-dump-context@master
- name: Info
run: |
echo "This is triggered by ${{ github.event_name }}." >> $GITHUB_STEP_SUMMARY
echo "Github action is ${{ github.event.action }}." >> $GITHUB_STEP_SUMMARY
build:
runs-on: ubuntu-latest
needs:
- trigger
steps:
- uses: RDXWorks-actions/checkout@main
with:
fetch-depth: 0
- name: Dump context
uses: RDXWorks-actions/ghaction-dump-context@master
- uses: ./.github/actions/build
with:
active_network_name: ${{ env.active_network }}
release_network_name: ${{ env.release_network }}
- name: Turbo Worfkflow
run: npx turbo run lint prettier coverage svelte:check --filter=console
setup-tags:
runs-on: ubuntu-latest
needs:
- trigger
steps:
- uses: RDXWorks-actions/checkout@main
with:
fetch-depth: 0
- name: Docker tags for console
id: console-tags
uses: RDXWorks-actions/metadata-action@master
with:
images: |
docker.io/radixdlt/dapps-console
tags: |
type=sha,event=pr
type=sha,event=branch
type=semver,pattern={{version}}
- name: Define network name
run: |
if [ "${{ github.event_name}}" = 'workflow_dispatch' ]; then
echo "NETWORK_NAME="${{ github.event.inputs.ENVIRONMENT_NAME }}"" >> $GITHUB_ENV
elif [ "${{ github.event.action }}" = "released" ]; then
echo "NETWORK_NAME=${{ env.release_network }}" >> $GITHUB_ENV
elif [ "${{ github.event.action }}" = "prereleased" ]; then
echo "NETWORK_NAME=${{ env.prerelease_network }}" >> $GITHUB_ENV
elif [ "${{ github.ref }}" = "refs/heads/main" -a "${{ github.event_name }}" = 'push' ] || [ "${{ github.event_name }}" = "pull_request" ]; then
echo "NETWORK_NAME=${{ env.active_network }}" >> $GITHUB_ENV
fi
- id: network
run: |
echo "network-name=${{ env.NETWORK_NAME }}" >> $GITHUB_OUTPUT
- id: tag-with-network
run: |
echo "tag-with-network=${{github.sha}}-${{ env.NETWORK_NAME }}" >> $GITHUB_OUTPUT
- run: |
echo "$GITHUB_OUTPUT"
- name: Output tag value to job summary
run: |
echo "network-name=${{ steps.network.outputs.network-name }}" >> $GITHUB_STEP_SUMMARY
echo "docker-tag=${{ steps.tag-with-network.outputs.tag-with-network }}" >> $GITHUB_STEP_SUMMARY
outputs:
console-tags: ${{ steps.console-tags.outputs.tags }}
console-labels: ${{ steps.console-tags.outputs.labels }}
console-json: ${{ steps.console-tags.outputs.json }}
tag-with-network: ${{steps.tag-with-network.outputs.tag-with-network}}
network-name: ${{steps.network.outputs.network-name}}
phylum_analyze:
if: ${{ github.event.pull_request }}
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/phylum-analyze.yml@main
secrets:
phylum_api_key: ${{ secrets.PHYLUM_API_KEY }}
with:
phylum_pr_number: ${{ github.event.number }}
phylum_pr_name: ${{ github.head_ref }}
phylum_group_name: dApp-engineering
phylum_project_id: 70969afc-325a-413c-8001-2092940e0d7d
github_repository: ${{ github.repository }}
add_report_comment_to_pull_request: true
snyk-scan-deps-licences:
runs-on: ubuntu-latest
needs:
- trigger
steps:
- uses: RDXWorks-actions/checkout@main
- uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access'
app_name: 'console'
step_name: 'snyk-scan-deps-licenses'
secret_prefix: 'SNYK'
secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/snyk-credentials-rXRpuX'
parse_json: true
- name: Run Snyk to check for deps vulnerabilities
uses: RDXWorks-actions/snyk-actions/node@master
continue-on-error: true
with:
args: --all-projects --org=${{ env.SNYK_PROJECTS_ORG_ID }} --severity-threshold=critical
snyk-scan-code:
runs-on: ubuntu-latest
needs:
- trigger
steps:
- uses: RDXWorks-actions/checkout@main
- uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access'
app_name: 'console'
step_name: 'snyk-scan-code'
secret_prefix: 'SNYK'
secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/snyk-credentials-rXRpuX'
parse_json: true
- name: Run Snyk to check for code vulnerabilities
uses: RDXWorks-actions/snyk-actions/node@master
continue-on-error: true # temporary until code fix
with:
args: --all-projects --org=${{ env.SNYK_PROJECTS_ORG_ID }} --severity-threshold=high
command: code test
snyk-sbom:
runs-on: ubuntu-latest
permissions: write-all
needs:
- snyk-scan-deps-licences
- snyk-scan-code
steps:
- uses: RDXWorks-actions/checkout@main
- uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access'
app_name: 'console'
step_name: 'snyk-sbom'
secret_prefix: 'SNYK'
secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/snyk-credentials-rXRpuX'
parse_json: true
- name: Generate SBOM # check SBOM can be generated but nothing is done with it
uses: RDXWorks-actions/snyk-actions/node@master
with:
args: --all-projects --org=${{ env.SNYK_PROJECTS_ORG_ID }} --format=cyclonedx1.4+json --json-file-output sbom.json
command: sbom
- name: Upload SBOM
if: github.event_name == 'release'
uses: RDXWorks-actions/upload-release-assets@c94805dc72e4b20745f543da0f62eaee7722df7a
with:
files: sbom.json
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ github.event.release.tag_name }}
snyk-monitor:
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
needs:
- setup-tags
- push-console
steps:
- uses: RDXWorks-actions/checkout@main
- uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access'
app_name: 'console'
step_name: 'snyk-monitor'
secret_prefix: 'SNYK'
secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/snyk-credentials-rXRpuX'
parse_json: true
- name: Enable Snyk online monitoring to check for vulnerabilities
uses: RDXWorks-actions/snyk-actions/node@master
with:
args: --all-projects --org=${{ env.SNYK_PROJECTS_ORG_ID }} --target-reference=${{ github.ref_name }}
command: monitor
snyk-container-monitor:
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
needs:
- setup-tags
- push-console
steps:
- uses: radixdlt/public-iac-resuable-artifacts/snyk-container-monitor@main
with:
role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-common-secrets-read-access'
app_name: 'console'
dockerhub_secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/dockerhub-credentials'
snyk_secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/common/snyk-credentials-rXRpuX'
snyk_org_id: ${{ secrets.SNYK_ORG_ID }}
image: docker.io/radixdlt/dapps-console:${{ needs.setup-tags.outputs.tag-with-network }}
target_ref: ${{ github.ref_name }}
sonar:
runs-on: ubuntu-latest
needs:
- trigger
steps:
- uses: RDXWorks-actions/checkout@main
with:
fetch-depth: 0
- name: Use Node.js
uses: RDXWorks-actions/setup-node@main
with:
always-auth: true
node-version: 20.3.0
- uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: 'arn:aws:iam::${{ secrets.SECRETS_ACCOUNT_ID }}:role/gh-dapps-monorepo-secrets-read-access'
app_name: 'console'
step_name: 'sonar'
secret_prefix: 'GH'
secret_name: 'arn:aws:secretsmanager:eu-west-2:${{ secrets.SECRETS_ACCOUNT_ID }}:secret:github-actions/radixdlt/dapps-monorepo/console/sonar-token-xXTI1Y'
parse_json: true
- name: SonarCloud Scan
uses: RDXWorks-actions/sonarcloud-github-action@master
with:
projectBaseDir: ./apps/console
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ env.GH_SONAR_TOKEN }}
push-console:
name: (PRIVATE) Docker AMD
needs:
- setup-tags
- snyk-scan-deps-licences
- snyk-scan-code
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/docker-build.yml@main
with:
runs_on: selfhosted-ubuntu-22.04
image_registry: 'docker.io'
image_organization: 'radixdlt'
target: 'console'
image_name: 'dapps-console'
tag: ${{ needs.setup-tags.outputs.tag-with-network }}
context: '.'
dockerfile: './Dockerfile'
platforms: 'linux/amd64'
scan_image: false
provenance: false
snyk_target_ref: ${{ github.ref_name }}
with_sbom: false
build-args: |
NETWORK_NAME=${{ needs.setup-tags.outputs.network-name }}
NPM_LOCAL_CACHE=.cache/
deploy_pull_request:
if: ${{ github.event.pull_request }}
name: Deploy PR
needs:
- push-console
- setup-tags
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/jenkins-deployment.yml@main
with:
jenkins_job_name: "kubernetes-deployments/job/dapps-console"
github_branch: "${{ github.head_ref }}"
application_name: "dapps-console"
hierarchical_namespace: "dapps-console-ci-pr"
create_subnamespace: "true"
kubernetes_namespace: "dapps-console-pr-${{ github.event.number }}"
aws_eks_cluster: "rdx-works-main-dev"
aws_iam_role_name: "jenkins-dapps-console-pr-deployer"
helmfile_environment: "pr"
helm_dir: "deploy/helm/console"
helmfile_extra_vars: "ci.tag=${{ needs.setup-tags.outputs.tag-with-network }},ci.prNumber=${{ github.event.number }}"
secrets:
aws_deployment_account_id: ${{ secrets.AWS_DEV_ACCOUNT_ID }}
secrets_account_id: ${{ secrets.SECRETS_ACCOUNT_ID }}
deploy_dev:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
name: Deploy DEV
needs:
- push-console
- setup-tags
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/jenkins-deployment.yml@main
with:
github_environment: "console-dev"
github_branch: "${{ github.ref }}"
jenkins_job_name: "kubernetes-deployments/job/dapps-console"
application_name: "dapps-console"
kubernetes_namespace: "dapps-console-dev"
aws_eks_cluster: "rdx-works-main-dev"
aws_iam_role_name: "jenkins-dapps-console-dev-deployer"
helmfile_environment: "dev"
helm_dir: "deploy/helm/console"
helmfile_extra_vars: "ci.tag=${{ needs.setup-tags.outputs.tag-with-network }}"
secrets:
aws_deployment_account_id: ${{ secrets.AWS_DEV_ACCOUNT_ID }}
secrets_account_id: ${{ secrets.SECRETS_ACCOUNT_ID }}
deploy_enkinet:
if: >
( github.event.inputs.ENVIRONMENT_NAME == 'enkinet' && github.event_name == 'workflow_dispatch' )
name: Deploy ENKINET
needs:
- push-console
- setup-tags
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/jenkins-deployment.yml@main
with:
github_environment: "console-enkinet"
github_branch: "${{ github.ref }}"
jenkins_job_name: "kubernetes-deployments/job/dapps-console"
application_name: "dapps-console"
kubernetes_namespace: "dapps-console-enkinet"
aws_eks_cluster: "rdx-works-main-dev"
aws_iam_role_name: "jenkins-dapps-console-dev-deployer"
helmfile_environment: "enkinet"
helm_dir: "deploy/helm/console"
helmfile_extra_vars: "ci.tag=${{ needs.setup-tags.outputs.tag-with-network }}"
secrets:
aws_deployment_account_id: ${{ secrets.AWS_DEV_ACCOUNT_ID }}
secrets_account_id: ${{ secrets.SECRETS_ACCOUNT_ID }}
deploy_dumunet:
if: >
( github.event.inputs.ENVIRONMENT_NAME == 'dumunet' && github.event_name == 'workflow_dispatch' )
name: Deploy DUMUNET
needs:
- push-console
- setup-tags
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/jenkins-deployment.yml@main
with:
github_environment: "console-dumunet"
github_branch: "${{ github.ref }}"
jenkins_job_name: "kubernetes-deployments/job/dapps-console"
application_name: "dapps-console"
kubernetes_namespace: "dapps-console-dumunet"
aws_eks_cluster: "rdx-works-main-dev"
aws_iam_role_name: "jenkins-dapps-console-dev-deployer"
helmfile_environment: "dumunet"
helm_dir: "deploy/helm/console"
helmfile_extra_vars: "ci.tag=${{ needs.setup-tags.outputs.tag-with-network }}"
secrets:
aws_deployment_account_id: ${{ secrets.AWS_DEV_ACCOUNT_ID }}
secrets_account_id: ${{ secrets.SECRETS_ACCOUNT_ID }}
deploy_hammunet:
if: >
( github.event.inputs.ENVIRONMENT_NAME == 'hammunet' && github.event_name == 'workflow_dispatch' )
name: Deploy HAMMUNET
needs:
- push-console
- setup-tags
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/jenkins-deployment.yml@main
with:
github_environment: "console-hammunet"
github_branch: "${{ github.ref }}"
jenkins_job_name: "kubernetes-deployments/job/dapps-console"
application_name: "dapps-console"
kubernetes_namespace: "dapps-console-hammunet"
aws_eks_cluster: "rdx-works-main-dev"
aws_iam_role_name: "jenkins-dapps-console-dev-deployer"
helmfile_environment: "hammunet"
helm_dir: "deploy/helm/console"
helmfile_extra_vars: "ci.tag=${{ needs.setup-tags.outputs.tag-with-network }}"
secrets:
aws_deployment_account_id: ${{ secrets.AWS_DEV_ACCOUNT_ID }}
secrets_account_id: ${{ secrets.SECRETS_ACCOUNT_ID }}
deploy_stokenet:
if: github.event_name == 'release' && github.event.action == 'prereleased'
name: Deploy STOKENET
needs:
- push-console
- setup-tags
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/jenkins-deployment.yml@main
with:
github_environment: "console-stokenet"
github_branch: "${{ github.ref }}"
jenkins_job_name: "kubernetes-deployments/job/dapps-console"
application_name: "dapps-console"
kubernetes_namespace: "dapps-console-stokenet"
aws_eks_cluster: "rtlj-prod"
aws_iam_role_name: "jenkins-dapps-console-stokenet-deployer"
helmfile_environment: "stokenet"
helm_dir: "deploy/helm/console"
helmfile_extra_vars: "ci.tag=${{ needs.setup-tags.outputs.tag-with-network }}"
secrets:
aws_deployment_account_id: ${{ secrets.AWS_PROD_ACCOUNT_ID }}
secrets_account_id: ${{ secrets.SECRETS_ACCOUNT_ID }}
deploy_mainnet:
if: github.event_name == 'release' && github.event.action == 'released'
name: Deploy MAINNET
needs:
- push-console
- setup-tags
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/jenkins-deployment.yml@main
with:
github_environment: "console-mainnet"
github_branch: "${{ github.ref }}"
jenkins_job_name: "kubernetes-deployments/job/dapps-console"
application_name: "dapps-console"
kubernetes_namespace: "dapps-console-mainnet"
aws_eks_cluster: "rtlj-prod"
aws_iam_role_name: "jenkins-dapps-console-mainnet-deployer"
helmfile_environment: "mainnet"
helm_dir: "deploy/helm/console"
helmfile_extra_vars: "ci.tag=${{ needs.setup-tags.outputs.tag-with-network }}"
secrets:
aws_deployment_account_id: ${{ secrets.AWS_PROD_ACCOUNT_ID }}
secrets_account_id: ${{ secrets.SECRETS_ACCOUNT_ID }}