1- name : Deploy All
1+ name : Build and deploy
22
33on :
44 push :
@@ -20,25 +20,42 @@ permissions:
2020 id-token : write
2121
2222jobs :
23- deploy :
23+ build :
24+ runs-on : ubuntu-latest
25+ steps :
26+ - uses : actions/checkout@v5
27+ - name : Parse .tool-versions
28+ uses : ./.github/actions/parse-tool-versions
29+ id : tool-versions
30+ - uses : actions/setup-node@v5
31+ with :
32+ node-version : ${{ fromJSON(steps.tool-versions.outputs.versions).nodejs }}
33+ cache : ' yarn'
34+ - run : node -v
35+ - run : yarn set version ${{ fromJSON(steps.tool-versions.outputs.versions).yarn }}
36+ - run : yarn install --inmutable
37+ - run : yarn build:prod
38+ - name : Upload dist bundle
39+ uses : actions/upload-artifact@v4
40+ with :
41+ name : dist-artifact
42+ path : dist
43+
44+ infra :
2445 runs-on : ubuntu-latest
46+ outputs :
47+ tf_output : ${{ steps.tf_output.outputs.json}}
2548 env :
2649 TF_IN_AUTOMATION : true
2750 steps :
2851 - uses : actions/checkout@v5
52+ - name : Parse .tool-versions
53+ uses : ./.github/actions/parse-tool-versions
54+ id : tool-versions
2955 - uses : aws-actions/configure-aws-credentials@v5.0.0
3056 with :
3157 role-to-assume : ${{ secrets.AWS_ROLE }}
3258 aws-region : ${{ env.TF_VAR_aws_region }}
33-
34- - name : Parse .tool-versions
35- uses : ./.github/actions/parse-tool-versions
36- id : tool-versions
37-
38- - name : Show versions
39- run : echo ${{ steps.tool-versions.outputs.versions }}
40-
41- # Infra setup steps
4259 - uses : hashicorp/setup-terraform@v3
4360 with :
4461 terraform_version : ${{ fromJSON(steps.tool-versions.outputs.versions).terraform }}
4865 -backend-config="bucket=${{env.TF_VAR_project}}-tfbackend" \
4966 -backend-config="region=${{env.TF_VAR_aws_region}}"
5067 working-directory : ./terraform
51-
5268 - run : terraform plan -out=tfplan -input=false
5369 working-directory : ./terraform
5470 - run : terraform apply -input=false tfplan
@@ -57,25 +73,26 @@ jobs:
5773 working-directory : ./terraform
5874 id : tf_output
5975
60- # Website build steps
61- - uses : actions/setup-node@v5
76+ deploy :
77+ runs-on : ubuntu-latest
78+ needs : [build, infra]
79+ steps :
80+ - uses : aws-actions/configure-aws-credentials@v5.0.0
6281 with :
63- node-version : ${{ fromJSON(steps.tool-versions.outputs.versions).nodejs }}
64- cache : ' yarn'
65- - run : node -v
66- - run : yarn set version ${{ fromJSON(steps.tool-versions.outputs.versions).yarn }}
67- - run : yarn install --inmutable
68- - run : yarn build:prod
69-
70- # Deploy steps
82+ role-to-assume : ${{ secrets.AWS_ROLE }}
83+ aws-region : ${{ env.TF_VAR_aws_region }}
84+ - name : Download dist artifact
85+ uses : actions/download-artifact@v4
86+ with :
87+ name : dist-artifact
88+ path : dist
7189 - name : Sync to S3
7290 env :
73- S3_BUCKET_NAME : ${{ fromJson(steps.tf_output .outputs.json ).s3_bucket_name.value }}
91+ S3_BUCKET_NAME : ${{ fromJson(needs.infra .outputs.tf_output ).s3_bucket_name.value }}
7492 run : aws s3 sync ./dist s3://${{env.S3_BUCKET_NAME}}/ --delete
75-
7693 - name : Invalidate CloudFront
7794 env :
78- CLOUDFRONT_DIST_ID : ${{ fromJson(steps.tf_output .outputs.json ).cloudfront_dist_id.value }}
95+ CLOUDFRONT_DIST_ID : ${{ fromJson(needs.infra .outputs.tf_output ).cloudfront_dist_id.value }}
7996 run : |
8097 aws cloudfront create-invalidation \
8198 --distribution-id ${{env.CLOUDFRONT_DIST_ID}} \
0 commit comments