Skip to content

Commit 0805871

Browse files
authored
Merge pull request #4788 from nhsuk/fix_data_replication
Fix data replication workflow
2 parents aa8be83 + 94d5fe4 commit 0805871

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

.github/workflows/data-replication-pipeline.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ env:
3030
db_snapshot_arn: ${{ inputs.db_snapshot_arn }}
3131
egress_cidr: ${{ inputs.egress_cidr }}
3232
take_db_snapshot: ${{ inputs.take_db_snapshot }}
33-
git_ref: ${{ inputs.git_ref_to_deploy || github.sha }}
33+
git_ref_to_deploy: ${{ inputs.git_ref_to_deploy || github.sha }}
3434
aws_role: ${{ inputs.environment == 'production'
3535
&& 'arn:aws:iam::820242920762:role/GithubDeployDataReplicationInfrastructure'
3636
|| 'arn:aws:iam::393416225559:role/GithubDeployDataReplicationInfrastructure' }}
@@ -63,7 +63,7 @@ jobs:
6363
- name: Checkout code
6464
uses: actions/checkout@v5
6565
with:
66-
ref: ${{ env.git_ref }}
66+
ref: ${{ env.git_ref_to_deploy }}
6767
- name: Get git sha
6868
id: get-git-sha
6969
run: echo "git-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
@@ -79,14 +79,14 @@ jobs:
7979
prepare-deployment:
8080
name: Prepare deployment
8181
runs-on: ubuntu-latest
82-
needs: build-and-push-image
82+
needs: [build-and-push-image, determine-git-sha]
8383
permissions:
8484
id-token: write
8585
steps:
8686
- name: Checkout code
8787
uses: actions/checkout@v5
8888
with:
89-
ref: ${{ env.git_ref }}
89+
ref: ${{ env.git_ref_to_deploy }}
9090
- name: Configure AWS Credentials
9191
uses: aws-actions/configure-aws-credentials@v5
9292
with:
@@ -97,7 +97,7 @@ jobs:
9797
run: |
9898
digest=$(aws ecr describe-images \
9999
--repository-name mavis/webapp \
100-
--image-ids imageTag=$git_ref \
100+
--image-ids imageTag=${{ needs.determine-git-sha.outputs.git-sha }} \
101101
--query 'imageDetails[0].imageDigest' \
102102
--output text)
103103
echo "digest=$digest" >> $GITHUB_OUTPUT

.github/workflows/refresh-data-replication.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ on:
3232
permissions: {}
3333

3434
env:
35+
environment: ${{ inputs.environment }}
3536
db_snapshot_arn: ${{ inputs.db_snapshot_arn }}
37+
egress_cidr: ${{ inputs.egress_cidr }}
3638
aws_role: ${{ inputs.environment == 'production'
3739
&& 'arn:aws:iam::820242920762:role/GithubDeployDataReplicationInfrastructure'
3840
|| 'arn:aws:iam::393416225559:role/GithubDeployDataReplicationInfrastructure' }}
@@ -99,7 +101,7 @@ jobs:
99101
- name: Install terraform
100102
uses: hashicorp/setup-terraform@v3
101103
with:
102-
terraform_version: 1.11.4
104+
terraform_version: 1.13.3
103105
outputs:
104106
SNAPSHOT_ARN: ${{ steps.get-latest-snapshot.outputs.SNAPSHOT_ARN }}
105107

@@ -124,7 +126,7 @@ jobs:
124126
- name: Install terraform
125127
uses: hashicorp/setup-terraform@v3
126128
with:
127-
terraform_version: 1.11.4
129+
terraform_version: 1.13.3
128130
- name: Get db secret arn
129131
id: get-db-secret-arn
130132
working-directory: terraform/app
@@ -204,7 +206,7 @@ jobs:
204206
- name: Install terraform
205207
uses: hashicorp/setup-terraform@v3
206208
with:
207-
terraform_version: 1.11.4
209+
terraform_version: 1.13.3
208210
- name: Apply the changes
209211
run: |
210212
set -e

terraform/data_replication/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ locals {
7070
{
7171
name = "DB_NAME"
7272
value = aws_rds_cluster.cluster.database_name
73+
},
74+
{
75+
name = "RAILS_ENV"
76+
value = var.environment == "production" ? "production" : "staging"
7377
}
7478
]
7579
task_secrets = [

0 commit comments

Comments
 (0)