1- name : ' Deploy to Pre-Prod'
1+ name : " Deploy to Pre-Prod"
22
33on :
44 workflow_dispatch :
1212permissions :
1313 pull-requests : write
1414 id-token : write # This is required for requesting the JWT
15- contents : read # This is required for actions/checkout
16-
15+ contents : read # This is required for actions/checkout
16+
1717jobs :
1818 tag_and_release :
1919 runs-on : ubuntu-latest
@@ -22,75 +22,81 @@ jobs:
2222 permissions : write-all
2323
2424 steps :
25- - name : Checkout main
26- if : ${{ github.event.inputs.branch_or_tag == 'main' }}
27- uses : actions/checkout@v4
28- with :
29- ref : main
30- fetch-depth : ' 0 '
31-
32- - name : Bump version and push tag
33- if : ${{ github.event.inputs.branch_or_tag == 'main' }}
34- id : versioning
35- uses :
anothrNick/[email protected] 36- env :
37- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
38- WITH_V : false
39- DEFAULT_BUMP : patch
40-
41- - name : View outputs
42- run : |
43- echo Deploying branch or tagged version to pre-prod: ${{ steps.versioning.outputs.tag || github.event.inputs.branch_or_tag }}
25+ - name : Checkout main
26+ if : ${{ github.event.inputs.branch_or_tag == 'main' }}
27+ uses : actions/checkout@v4
28+ with :
29+ ref : main
30+ fetch-depth : " 0 "
31+
32+ - name : Bump version and push tag
33+ if : ${{ github.event.inputs.branch_or_tag == 'main' }}
34+ id : versioning
35+ uses :
anothrNick/[email protected] 36+ env :
37+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
38+ WITH_V : false
39+ DEFAULT_BUMP : patch
40+
41+ - name : View outputs
42+ run : |
43+ echo Deploying branch or tagged version to pre-prod: ${{ steps.versioning.outputs.tag || github.event.inputs.branch_or_tag }}
4444
4545 terraform_process :
4646 runs-on : ubuntu-latest
47- needs : [' tag_and_release' ]
47+ needs : [" tag_and_release" ]
4848 environment : pre-prod
4949
5050 steps :
51- - name : Checkout
52- uses : actions/checkout@v4
53- with :
54- ref : ${{needs.tag_and_release.outputs.version}}
55- fetch-depth : ' 0'
56-
57- - name : Configure AWS Credentials
58- uses : aws-actions/configure-aws-credentials@v4
59- with :
60- role-to-assume : ${{ secrets.AWS_ASSUME_ROLE }}
61- role-skip-session-tagging : true
62- aws-region : ${{ vars.AWS_REGION }}
63- mask-aws-account-id : true
64-
65- - name : Setup Terraform
66- uses : hashicorp/setup-terraform@v3
67- with :
68- terraform_version : 1.11.4
69- terraform_wrapper : false
70-
71- - name : Terraform Init
72- id : init
73- run : terraform init -backend-config=backend-pre-prod.conf
74- working-directory : ./infrastructure
75- shell : bash
76-
77- - name : Terraform Set Workspace
78- id : workspace
79- run : terraform workspace select ${{ secrets.AWS_WORKSPACE }}
80- working-directory : ./infrastructure
81- shell : bash
82-
83- - name : Terraform Format
84- run : terraform fmt -check
85- working-directory : ./infrastructure
86-
87- - name : Terraform Plan
88- id : plan
89- run : |
90- terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf.plan
91- working-directory : ./infrastructure
92- shell : bash
93-
94- - name : Terraform Apply
95- run : terraform apply -auto-approve -input=false tf.plan
96- working-directory : ./infrastructure
51+ - name : Checkout
52+ uses : actions/checkout@v4
53+ with :
54+ ref : ${{needs.tag_and_release.outputs.version}}
55+ fetch-depth : " 0"
56+
57+ - name : Configure AWS Credentials
58+ uses : aws-actions/configure-aws-credentials@v4
59+ with :
60+ role-to-assume : ${{ secrets.AWS_ASSUME_ROLE }}
61+ role-skip-session-tagging : true
62+ aws-region : ${{ vars.AWS_REGION }}
63+ mask-aws-account-id : true
64+
65+ - name : Setup Terraform
66+ uses : hashicorp/setup-terraform@v3
67+ with :
68+ terraform_version : 1.11.4
69+ terraform_wrapper : false
70+
71+ - name : Terraform Init
72+ id : init
73+ run : terraform init -backend-config=backend-pre-prod.conf
74+ working-directory : ./infrastructure
75+ shell : bash
76+
77+ - name : Terraform Set Workspace
78+ id : workspace
79+ run : terraform workspace select ${{ secrets.AWS_WORKSPACE }}
80+ working-directory : ./infrastructure
81+ shell : bash
82+
83+ - name : Lambda Layer Imports
84+ id : lambda_layer_import
85+ run : ./import_lambda_layers.sh ${{ secrets.AWS_WORKSPACE }} ${{ vars.TF_VARS_FILE }}
86+ working-directory : ./scripts
87+ shell : bash
88+
89+ - name : Terraform Format
90+ run : terraform fmt -check
91+ working-directory : ./infrastructure
92+
93+ - name : Terraform Plan
94+ id : plan
95+ run : |
96+ terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf.plan
97+ working-directory : ./infrastructure
98+ shell : bash
99+
100+ - name : Terraform Apply
101+ run : terraform apply -auto-approve -input=false tf.plan
102+ working-directory : ./infrastructure
0 commit comments