3939 uses : actions/checkout@v6
4040 with :
4141 ref : ${{ inputs.ref }}
42- fetch-depth : 0 # get full history + tags
42+ fetch-depth : 0 # get full history + tags
4343
4444 - name : " Set CI/CD variables"
4545 id : variables
@@ -104,61 +104,60 @@ jobs:
104104 fi
105105
106106 download-lambda-artifact :
107- name : " Fetch the lambda artifact from previous stage"
108- runs-on : ubuntu-latest
109- needs : [metadata]
110- timeout-minutes : 45
111- permissions :
112- id-token : write
113- contents : write
114- environment : ${{ needs.metadata.outputs.promoted_environment }}
115- steps :
116- - name : " Checkout repository at ref"
117- uses : actions/checkout@v6
118- with :
119- ref : ${{ needs.metadata.outputs.ref }}
120- fetch-depth : 0
121-
122- - name : " Setup Terraform"
123- uses : hashicorp/setup-terraform@v3
124- with :
125- terraform_version : ${{ needs.metadata.outputs.terraform_version }}
107+ name : " Fetch the lambda artifact from previous stage"
108+ runs-on : ubuntu-latest
109+ needs : [metadata]
110+ timeout-minutes : 45
111+ permissions :
112+ id-token : write
113+ contents : write
114+ environment : ${{ needs.metadata.outputs.promoted_environment }}
115+ steps :
116+ - name : " Checkout repository at ref"
117+ uses : actions/checkout@v6
118+ with :
119+ ref : ${{ needs.metadata.outputs.ref }}
120+ fetch-depth : 0
126121
127- - name : " Configure AWS Credentials"
128- uses : aws-actions/configure-aws-credentials@v6
129- with :
130- role-to-assume : arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
131- aws-region : eu-west-2
122+ - name : " Setup Terraform"
123+ uses : hashicorp/setup-terraform@v3
124+ with :
125+ terraform_version : ${{ needs.metadata.outputs.terraform_version }}
132126
133- - name : " Terraform Init"
134- env :
135- ENVIRONMENT : ${{ needs.metadata.outputs.promoted_environment }}
136- WORKSPACE : " default"
137- run : |
138- echo "Running: make terraform env=$ENVIRONMENT workspace=$WORKSPACE stack=api-layer tf-command=init"
139- make terraform env=$ENVIRONMENT stack=api-layer tf-command=init workspace=$WORKSPACE
140- working-directory : ./infrastructure
127+ - name : " Configure AWS Credentials"
128+ uses : aws-actions/configure-aws-credentials@v6
129+ with :
130+ role-to-assume : arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
131+ aws-region : eu-west-2
141132
142- - name : " Extract S3 bucket name from Terraform output"
143- id : tf_output
144- run : |
145- BUCKET=$(terraform output -raw lambda_artifact_bucket)
146- echo "bucket_name=$BUCKET" >> $GITHUB_OUTPUT
147- working-directory : ./infrastructure/stacks/api-layer
133+ - name : " Terraform Init"
134+ env :
135+ ENVIRONMENT : ${{ needs.metadata.outputs.promoted_environment }}
136+ WORKSPACE : " default"
137+ run : |
138+ echo "Running: make terraform env=$ENVIRONMENT workspace=$WORKSPACE stack=api-layer tf-command=init"
139+ make terraform env=$ENVIRONMENT stack=api-layer tf-command=init workspace=$WORKSPACE
140+ working-directory : ./infrastructure
148141
149- - name : " Download lambda artifact from S3 "
150- run : |
151- aws s3 cp \
152- s3://${{ steps.tf_output.outputs.bucket_name }}/artifacts/${{ needs.metadata.outputs.tag }}/lambda.zip \
153- ./dist/lambda.zip \
154- --region eu-west-2
142+ - name : " Extract S3 bucket name from Terraform output "
143+ id : tf_output
144+ run : |
145+ BUCKET=$(terraform output -raw lambda_artifact_bucket)
146+ echo "bucket_name=$BUCKET" >> $GITHUB_OUTPUT
147+ working-directory : ./infrastructure/stacks/api-layer
155148
156- - name : " Upload lambda artifact for the current workflow"
157- uses : actions/upload-artifact@v6
158- with :
159- name : lambda-${{ needs.metadata.outputs.tag }}
160- path : ./dist/lambda.zip
149+ - name : " Download lambda artifact from S3"
150+ run : |
151+ aws s3 cp \
152+ s3://${{ steps.tf_output.outputs.bucket_name }}/artifacts/${{ needs.metadata.outputs.tag }}/lambda.zip \
153+ ./dist/lambda.zip \
154+ --region eu-west-2
161155
156+ - name : " Upload lambda artifact for the current workflow"
157+ uses : actions/upload-artifact@v6
158+ with :
159+ name : lambda-${{ needs.metadata.outputs.tag }}
160+ path : ./dist/lambda.zip
162161
163162 deploy :
164163 name : " Deploy to ${{ needs.metadata.outputs.environment }}"
@@ -264,7 +263,6 @@ jobs:
264263 s3://${{ steps.tf_output.outputs.bucket_name }}/artifacts/${{ steps.release_tag.outputs.release_tag }}/lambda.zip \
265264 --region eu-west-2
266265
267-
268266 regression-tests :
269267 name : " Regression Tests"
270268 if : ${{ needs.metadata.outputs.environment == 'preprod' }}
@@ -273,4 +271,5 @@ jobs:
273271 with :
274272 ENVIRONMENT : " preprod"
275273 VERSION_NUMBER : " main"
276- secrets : inherit
274+ secrets :
275+ AWS_ACCOUNT_ID : ${{ secrets.PREPROD_AWS_ACCOUNT_ID }}
0 commit comments