13
13
TESTING_PIPELINE_EXECUTION_ROLE : ${{ secrets.TESTING_PIPELINE_EXECUTION_ROLE }}
14
14
TESTING_CLOUDFORMATION_EXECUTION_ROLE : ${{ secrets.TESTING_CLOUDFORMATION_EXECUTION_ROLE }}
15
15
TESTING_ARTIFACTS_BUCKET : ${{ secrets.TESTING_ARTIFACTS_BUCKET }}
16
- TESTING_PARAMETER_OVERRIDES : TasksTableName=" tasks" ,CognitoCallbackURL=" https://start.spring.io/" ,UserPoolAdminGroupName=" apiAdmins"
16
+ TESTING_PARAMETER_OVERRIDES : TasksTableName=tasks,CognitoCallbackURL=https://start.spring.io/,UserPoolAdminGroupName=apiAdmins
17
17
# If there are functions with "Image" PackageType in your template,
18
18
# uncomment the line below and add "--image-repository ${TESTING_IMAGE_REPOSITORY}" to
19
19
# testing "sam package" and "sam deploy" commands.
23
23
PROD_PIPELINE_EXECUTION_ROLE : ${{ secrets.PROD_PIPELINE_EXECUTION_ROLE }}
24
24
PROD_CLOUDFORMATION_EXECUTION_ROLE : ${{ secrets.PROD_CLOUDFORMATION_EXECUTION_ROLE }}
25
25
PROD_ARTIFACTS_BUCKET : ${{ secrets.PROD_ARTIFACTS_BUCKET }}
26
- PRODUCTION_PARAMETER_OVERRIDES : TasksTableName=" tasks" ,CognitoCallbackURL=" https://django-rest-framework.org/tutorial/" ,UserPoolAdminGroupName=" apiAdmins"
26
+ PRODUCTION_PARAMETER_OVERRIDES : TasksTableName=tasks,CognitoCallbackURL=https://django-rest-framework.org/tutorial/,UserPoolAdminGroupName=apiAdmins
27
27
# If there are functions with "Image" PackageType in your template,
28
28
# uncomment the line below and add "--image-repository ${PROD_IMAGE_REPOSITORY}" to
29
29
# prod "sam package" and "sam deploy" commands.
39
39
- run : |
40
40
# trigger the tests here
41
41
42
- build-and-package :
42
+ build-and-package-for-production :
43
43
if : github.ref == 'refs/heads/main'
44
44
needs : [test]
45
45
runs-on : ubuntu-latest
@@ -52,54 +52,67 @@ jobs:
52
52
- name : Build resources
53
53
run : sam build --template ${SAM_TEMPLATE} --use-container
54
54
55
- - name : Assume the testing pipeline user role
55
+ - name : Assume the prod pipeline user role
56
56
uses : aws-actions/configure-aws-credentials@v4
57
57
with :
58
58
aws-access-key-id : ${{ env.PIPELINE_USER_ACCESS_KEY_ID }}
59
59
aws-secret-access-key : ${{ env.PIPELINE_USER_SECRET_ACCESS_KEY }}
60
- aws-region : ${{ env.TESTING_REGION }}
61
- role-to-assume : ${{ env.TESTING_PIPELINE_EXECUTION_ROLE }}
62
- role-session-name : testing -packaging
60
+ aws-region : ${{ env.PROD_REGION }}
61
+ role-to-assume : ${{ env.PROD_PIPELINE_EXECUTION_ROLE }}
62
+ role-session-name : prod -packaging
63
63
role-duration-seconds : 3600
64
64
role-skip-session-tagging : true
65
65
66
- - name : Upload artifacts to testing artifact buckets
66
+ - name : Upload artifacts to production artifact buckets
67
67
run : |
68
68
sam package \
69
- --s3-bucket ${TESTING_ARTIFACTS_BUCKET } \
70
- --region ${TESTING_REGION } \
71
- --output-template-file packaged-testing .yaml
69
+ --s3-bucket ${PROD_ARTIFACTS_BUCKET } \
70
+ --region ${PROD_REGION } \
71
+ --output-template-file packaged-prod .yaml
72
72
73
73
- uses : actions/upload-artifact@v4
74
74
with :
75
- name : packaged-testing .yaml
76
- path : packaged-testing .yaml
75
+ name : packaged-prod .yaml
76
+ path : packaged-prod .yaml
77
77
78
- - name : Assume the prod pipeline user role
78
+ build-and-package-for-testing :
79
+ if : github.ref == 'refs/heads/dev'
80
+ needs : [ test ]
81
+ runs-on : ubuntu-latest
82
+ steps :
83
+ - uses : actions/checkout@v3
84
+ - uses : aws-actions/setup-sam@v2
85
+ with :
86
+ use-installer : true
87
+
88
+ - name : Build resources
89
+ run : sam build --template ${SAM_TEMPLATE} --use-container
90
+
91
+ - name : Assume the testing pipeline user role
79
92
uses : aws-actions/configure-aws-credentials@v4
80
93
with :
81
94
aws-access-key-id : ${{ env.PIPELINE_USER_ACCESS_KEY_ID }}
82
95
aws-secret-access-key : ${{ env.PIPELINE_USER_SECRET_ACCESS_KEY }}
83
- aws-region : ${{ env.PROD_REGION }}
84
- role-to-assume : ${{ env.PROD_PIPELINE_EXECUTION_ROLE }}
85
- role-session-name : prod -packaging
96
+ aws-region : ${{ env.TESTING_REGION }}
97
+ role-to-assume : ${{ env.TESTING_PIPELINE_EXECUTION_ROLE }}
98
+ role-session-name : testing -packaging
86
99
role-duration-seconds : 3600
87
100
role-skip-session-tagging : true
88
101
89
- - name : Upload artifacts to production artifact buckets
102
+ - name : Upload artifacts to testing artifact buckets
90
103
run : |
91
104
sam package \
92
- --s3-bucket ${PROD_ARTIFACTS_BUCKET } \
93
- --region ${PROD_REGION } \
94
- --output-template-file packaged-prod .yaml
105
+ --s3-bucket ${TESTING_ARTIFACTS_BUCKET } \
106
+ --region ${TESTING_REGION } \
107
+ --output-template-file packaged-testing .yaml
95
108
96
109
- uses : actions/upload-artifact@v4
97
110
with :
98
- name : packaged-prod .yaml
99
- path : packaged-prod .yaml
111
+ name : packaged-testing .yaml
112
+ path : packaged-testing .yaml
100
113
101
114
deploy-testing :
102
- if : github.ref == 'refs/heads/main '
115
+ if : github.ref == 'refs/heads/dev '
103
116
needs : [build-and-package]
104
117
runs-on : ubuntu-latest
105
118
steps :
@@ -130,8 +143,8 @@ jobs:
130
143
--region ${TESTING_REGION} \
131
144
--s3-bucket ${TESTING_ARTIFACTS_BUCKET} \
132
145
--no-fail-on-empty-changeset \
133
- --role-arn ${TESTING_CLOUDFORMATION_EXECUTION_ROLE}
134
- --parameter-overrides TasksTableName=tasks,CognitoCallbackURL=https://start.spring.io/,UserPoolAdminGroupName=apiAdmins
146
+ --role-arn ${TESTING_CLOUDFORMATION_EXECUTION_ROLE} \
147
+ --parameter-overrides ${TESTING_PARAMETER_OVERRIDES}
135
148
136
149
integration-test :
137
150
if : github.ref == 'refs/heads/main'
@@ -177,5 +190,5 @@ jobs:
177
190
--region ${PROD_REGION} \
178
191
--s3-bucket ${PROD_ARTIFACTS_BUCKET} \
179
192
--no-fail-on-empty-changeset \
180
- --role-arn ${PROD_CLOUDFORMATION_EXECUTION_ROLE}
193
+ --role-arn ${PROD_CLOUDFORMATION_EXECUTION_ROLE} \
181
194
--parameter-overrides ${PRODUCTION_PARAMETER_OVERRIDES}
0 commit comments