Skip to content

Commit 4072a8c

Browse files
committed
update workflow pipeline.yaml
1 parent 7113da0 commit 4072a8c

File tree

1 file changed

+40
-27
lines changed

1 file changed

+40
-27
lines changed

.github/workflows/pipeline.yaml

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
TESTING_PIPELINE_EXECUTION_ROLE: ${{ secrets.TESTING_PIPELINE_EXECUTION_ROLE }}
1414
TESTING_CLOUDFORMATION_EXECUTION_ROLE: ${{ secrets.TESTING_CLOUDFORMATION_EXECUTION_ROLE }}
1515
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
1717
# If there are functions with "Image" PackageType in your template,
1818
# uncomment the line below and add "--image-repository ${TESTING_IMAGE_REPOSITORY}" to
1919
# testing "sam package" and "sam deploy" commands.
@@ -23,7 +23,7 @@ env:
2323
PROD_PIPELINE_EXECUTION_ROLE: ${{ secrets.PROD_PIPELINE_EXECUTION_ROLE }}
2424
PROD_CLOUDFORMATION_EXECUTION_ROLE: ${{ secrets.PROD_CLOUDFORMATION_EXECUTION_ROLE }}
2525
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
2727
# If there are functions with "Image" PackageType in your template,
2828
# uncomment the line below and add "--image-repository ${PROD_IMAGE_REPOSITORY}" to
2929
# prod "sam package" and "sam deploy" commands.
@@ -39,7 +39,7 @@ jobs:
3939
- run: |
4040
# trigger the tests here
4141
42-
build-and-package:
42+
build-and-package-for-production:
4343
if: github.ref == 'refs/heads/main'
4444
needs: [test]
4545
runs-on: ubuntu-latest
@@ -52,54 +52,67 @@ jobs:
5252
- name: Build resources
5353
run: sam build --template ${SAM_TEMPLATE} --use-container
5454

55-
- name: Assume the testing pipeline user role
55+
- name: Assume the prod pipeline user role
5656
uses: aws-actions/configure-aws-credentials@v4
5757
with:
5858
aws-access-key-id: ${{ env.PIPELINE_USER_ACCESS_KEY_ID }}
5959
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
6363
role-duration-seconds: 3600
6464
role-skip-session-tagging: true
6565

66-
- name: Upload artifacts to testing artifact buckets
66+
- name: Upload artifacts to production artifact buckets
6767
run: |
6868
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
7272
7373
- uses: actions/upload-artifact@v4
7474
with:
75-
name: packaged-testing.yaml
76-
path: packaged-testing.yaml
75+
name: packaged-prod.yaml
76+
path: packaged-prod.yaml
7777

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
7992
uses: aws-actions/configure-aws-credentials@v4
8093
with:
8194
aws-access-key-id: ${{ env.PIPELINE_USER_ACCESS_KEY_ID }}
8295
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
8699
role-duration-seconds: 3600
87100
role-skip-session-tagging: true
88101

89-
- name: Upload artifacts to production artifact buckets
102+
- name: Upload artifacts to testing artifact buckets
90103
run: |
91104
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
95108
96109
- uses: actions/upload-artifact@v4
97110
with:
98-
name: packaged-prod.yaml
99-
path: packaged-prod.yaml
111+
name: packaged-testing.yaml
112+
path: packaged-testing.yaml
100113

101114
deploy-testing:
102-
if: github.ref == 'refs/heads/main'
115+
if: github.ref == 'refs/heads/dev'
103116
needs: [build-and-package]
104117
runs-on: ubuntu-latest
105118
steps:
@@ -130,8 +143,8 @@ jobs:
130143
--region ${TESTING_REGION} \
131144
--s3-bucket ${TESTING_ARTIFACTS_BUCKET} \
132145
--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}
135148
136149
integration-test:
137150
if: github.ref == 'refs/heads/main'
@@ -177,5 +190,5 @@ jobs:
177190
--region ${PROD_REGION} \
178191
--s3-bucket ${PROD_ARTIFACTS_BUCKET} \
179192
--no-fail-on-empty-changeset \
180-
--role-arn ${PROD_CLOUDFORMATION_EXECUTION_ROLE}
193+
--role-arn ${PROD_CLOUDFORMATION_EXECUTION_ROLE} \
181194
--parameter-overrides ${PRODUCTION_PARAMETER_OVERRIDES}

0 commit comments

Comments
 (0)