Skip to content

Commit a4162b7

Browse files
committed
Refactor deployment workflow to reorder jobs and enhance Terraform planning
- Moved the `terraform-plan` job to depend on the `build-and-push-recordprocessor` job, ensuring a more logical sequence in the deployment process. - Retained the steps for AWS connection, Terraform initialization, and planning within the `terraform-plan` job, maintaining infrastructure management integrity. - Removed the previous `terraform-plan` job definition to streamline the workflow.
1 parent e05a26a commit a4162b7

1 file changed

Lines changed: 42 additions & 42 deletions

File tree

.github/workflows/deploy-backend.yml

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -51,53 +51,11 @@ env: # Sonarcloud - do not allow direct usage of untrusted data
5151
run-name: Deploy Backend - ${{ inputs.environment }} ${{ inputs.sub_environment }}
5252

5353
jobs:
54-
terraform-plan:
55-
permissions:
56-
id-token: write
57-
contents: read
58-
runs-on: ubuntu-latest
59-
env:
60-
TF_VAR_recordprocessor_image_tag: ${{ github.sha }}
61-
environment:
62-
name: ${{ inputs.environment }}
63-
steps:
64-
- name: Checkout
65-
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
66-
67-
- name: Connect to AWS
68-
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
69-
with:
70-
aws-region: eu-west-2
71-
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
72-
role-session-name: github-actions
73-
74-
- uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85
75-
with:
76-
terraform_version: "1.12.2"
77-
78-
- name: Terraform Init
79-
working-directory: infrastructure/instance
80-
run: make init
81-
82-
- name: Terraform Plan
83-
# Ignore cancellations to prevent Terraform from being killed while it holds a state lock
84-
# A stuck process can still be killed with the force-cancel API operation
85-
if: ${{ !failure() }}
86-
working-directory: infrastructure/instance
87-
run: make plan-ci
88-
89-
- name: Save Terraform Plan
90-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
91-
with:
92-
name: ${{ env.ENVIRONMENT }}-${{ env.SUB_ENVIRONMENT }}-tfplan
93-
path: infrastructure/instance/tfplan
94-
9554
build-and-push-recordprocessor:
9655
permissions:
9756
id-token: write
9857
contents: read
9958
name: Build and push recordprocessor image
100-
needs: terraform-apply
10159
runs-on: ubuntu-latest
10260

10361
environment:
@@ -134,6 +92,48 @@ jobs:
13492
docker build -f recordprocessor/Dockerfile -t "${IMAGE_URI}" .
13593
docker push "${IMAGE_URI}"
13694
95+
terraform-plan:
96+
permissions:
97+
id-token: write
98+
contents: read
99+
needs: build-and-push-recordprocessor
100+
runs-on: ubuntu-latest
101+
env:
102+
TF_VAR_recordprocessor_image_tag: ${{ github.sha }}
103+
environment:
104+
name: ${{ inputs.environment }}
105+
steps:
106+
- name: Checkout
107+
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
108+
109+
- name: Connect to AWS
110+
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
111+
with:
112+
aws-region: eu-west-2
113+
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
114+
role-session-name: github-actions
115+
116+
- uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85
117+
with:
118+
terraform_version: "1.12.2"
119+
120+
- name: Terraform Init
121+
working-directory: infrastructure/instance
122+
run: make init
123+
124+
- name: Terraform Plan
125+
# Ignore cancellations to prevent Terraform from being killed while it holds a state lock
126+
# A stuck process can still be killed with the force-cancel API operation
127+
if: ${{ !failure() }}
128+
working-directory: infrastructure/instance
129+
run: make plan-ci
130+
131+
- name: Save Terraform Plan
132+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
133+
with:
134+
name: ${{ env.ENVIRONMENT }}-${{ env.SUB_ENVIRONMENT }}-tfplan
135+
path: infrastructure/instance/tfplan
136+
137137
terraform-apply:
138138
permissions:
139139
id-token: write

0 commit comments

Comments
 (0)