23
23
BETA_ARTIFACTS_BUCKET : aws-sam-cli-managed-beta-pipeline-artifactsbucket-889nlo0z1nt0
24
24
BETA_IMAGE_REPOSITORY : 477159140107.dkr.ecr.ap-northeast-1.amazonaws.com/aws-sam-cli-managed-beta-pipeline-resources-imagerepository-0hbn3hxi9pcm
25
25
BETA_REGION : ap-northeast-1
26
+ PROD_ECR_PIPELINE_EXECUTION_ROLE : arn:aws:iam::373534280245:role/aws-sam-cli-managed-prod-ecr-PipelineExecutionRole-12FE9QIHNFYOI
27
+ PROD_ECR_CLOUDFORMATION_EXECUTION_ROLE : arn:aws:iam::373534280245:role/aws-sam-cli-managed-prod-CloudFormationExecutionR-RDUT9EAJJ1ZN
28
+ PROD_ARTIFACTS_BUCKET : aws-sam-cli-managed-prod-ecr-pipe-artifactsbucket-1mjporc66dkgn
29
+ PROD_IMAGE_REPOSITORY : 373534280245.dkr.ecr.us-east-1.amazonaws.com/aws-sam-cli-managed-prod-ecr-pipeline-resources-imagerepository-fhpoty0tapro
30
+ PROD_ECR_REGION : us-east-1
26
31
27
32
jobs :
28
33
test :
@@ -34,30 +39,14 @@ jobs:
34
39
toolchain : stable
35
40
components : clippy
36
41
- name : linting
37
- run : cargo fmt -- --check && cargo clippy -- -Dwarnings
42
+ run : |
43
+ cargo fmt -- --check
44
+ cargo clippy -- -Dwarnings
38
45
- run : cargo test
39
46
40
- load-gamma-matrix :
41
- needs : [ test ]
42
- runs-on : ubuntu-latest
43
- outputs :
44
- matrix : ${{ steps.set-matrix.outputs.matrix }}
45
- steps :
46
- - uses : actions/checkout@v2
47
- - id : set-matrix
48
- run : echo "::set-output name=matrix::{\"include\":$(jq -r tostring .github/workflows/gamma.json)}"
49
-
50
- load-prod-matrix :
51
- needs : [ test ]
52
- runs-on : ubuntu-latest
53
- outputs :
54
- matrix : ${{ steps.set-matrix.outputs.matrix }}
55
- steps :
56
- - uses : actions/checkout@v2
57
- - id : set-matrix
58
- run : echo "::set-output name=matrix::{\"include\":$(jq -r tostring .github/workflows/prod.json)}"
59
47
60
48
build :
49
+ if : ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
61
50
needs : [test]
62
51
runs-on : ubuntu-latest
63
52
steps :
81
70
name : aws-sam-build-arm64
82
71
path : build-arm64
83
72
73
+ load-gamma-matrix :
74
+ if : ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
75
+ needs : [ test ]
76
+ runs-on : ubuntu-latest
77
+ outputs :
78
+ matrix : ${{ steps.set-matrix.outputs.matrix }}
79
+ steps :
80
+ - uses : actions/checkout@v2
81
+ - id : set-matrix
82
+ run : echo "::set-output name=matrix::{\"include\":$(jq -r tostring .github/workflows/gamma.json)}"
83
+
84
+ load-prod-matrix :
85
+ if : ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
86
+ needs : [ test ]
87
+ runs-on : ubuntu-latest
88
+ outputs :
89
+ matrix : ${{ steps.set-matrix.outputs.matrix }}
90
+ steps :
91
+ - uses : actions/checkout@v2
92
+ - id : set-matrix
93
+ run : echo "::set-output name=matrix::{\"include\":$(jq -r tostring .github/workflows/prod.json)}"
84
94
85
95
package-beta :
96
+ if : ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
86
97
needs : [ build ]
87
98
runs-on : ubuntu-latest
88
99
steps :
@@ -141,6 +152,7 @@ jobs:
141
152
142
153
143
154
package-gamma :
155
+ if : ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
144
156
needs : [ build, load-gamma-matrix ]
145
157
runs-on : ubuntu-latest
146
158
strategy :
@@ -200,6 +212,7 @@ jobs:
200
212
path : packaged-gamma-arm64-${{ matrix.region }}.yaml
201
213
202
214
package-prod :
215
+ if : ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
203
216
needs : [ build, load-prod-matrix ]
204
217
runs-on : ubuntu-latest
205
218
strategy :
@@ -259,6 +272,7 @@ jobs:
259
272
path : packaged-prod-arm64-${{ matrix.region }}.yaml
260
273
261
274
deploy-beta :
275
+ if : ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
262
276
needs : [package-beta, package-gamma, package-prod]
263
277
runs-on : ubuntu-latest
264
278
steps :
@@ -308,6 +322,7 @@ jobs:
308
322
--role-arn ${BETA_CLOUDFORMATION_EXECUTION_ROLE}
309
323
310
324
integration-test :
325
+ if : ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
311
326
needs : [deploy-beta]
312
327
runs-on : ubuntu-latest
313
328
steps :
@@ -443,3 +458,30 @@ jobs:
443
458
--image-repository ${{ matrix.image_repository }} \
444
459
--no-fail-on-empty-changeset \
445
460
--role-arn ${{ matrix.cloudformation_execution_role }}
461
+
462
+ publish-to-public-ecr :
463
+ if : ${{ github.event_name == 'release' }}
464
+ needs : [deploy-prod]
465
+ runs-on : ubuntu-latest
466
+ steps :
467
+ - uses : actions/checkout@v2
468
+
469
+ - name : Assume the prod pipeline user role
470
+ uses : aws-actions/configure-aws-credentials@v1
471
+ with :
472
+ aws-access-key-id : ${{ env.PIPELINE_USER_ACCESS_KEY_ID }}
473
+ aws-secret-access-key : ${{ env.PIPELINE_USER_SECRET_ACCESS_KEY }}
474
+ aws-region : ${{ env.PROD_ECR_REGION }}
475
+ role-to-assume : ${{ env.PROD_ECR_PIPELINE_EXECUTION_ROLE }}
476
+ role-session-name : prod-deployment
477
+ role-duration-seconds : 3600
478
+ role-skip-session-tagging : true
479
+
480
+ - name : build OCI images for x86_64 and aarch64
481
+ run : |
482
+ make build-x86
483
+ make build-arm
484
+
485
+ - name : publish OCI images to ECR public repository
486
+ run : |
487
+ make publish
0 commit comments