Skip to content

Commit 401cd36

Browse files
committed
Nightly data replication refresh
This job deploys the data replication infrastructure each night with the latest DB snapshot.
1 parent dd75176 commit 401cd36

File tree

3 files changed

+77
-4
lines changed

3 files changed

+77
-4
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ on:
2121
Use code from: ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
2222
(Git ref to deploy, for example, a tag, branch name or commit SHA. Will use workflow ref if not provided.)
2323
type: string
24+
workflow_call:
25+
inputs:
26+
environment:
27+
description: Deployment environment
28+
required: true
29+
type: string
30+
git_ref_to_deploy:
31+
description: Git ref to deploy, for example, a tag, branch name or commit SHA
32+
type: string
33+
required: true
34+
skip_approval:
35+
description: Skip environment approval (auto-approve)
36+
type: boolean
37+
default: false
2438

2539
permissions: {}
2640

@@ -134,7 +148,7 @@ jobs:
134148
name: Notify on approval required
135149
runs-on: ubuntu-latest
136150
needs: prepare-deployment
137-
if: ${{ inputs.environment == 'production' }}
151+
if: ${{ inputs.environment == 'production' && inputs.skip_approval == 'false' }}
138152
steps:
139153
- name: Notify pending approval
140154
if: inputs.environment == 'production'
@@ -160,7 +174,7 @@ jobs:
160174
name: Wait for approval if required
161175
runs-on: ubuntu-latest
162176
needs: prepare-deployment
163-
environment: ${{ inputs.environment }}
177+
environment: ${{ inputs.skip_approval && null || inputs.environment }}
164178
steps:
165179
- run: echo "Proceeding with deployment to $environment environment"
166180

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,29 @@ on:
2828
description: Take a new DB snapshot before creating the environment
2929
type: boolean
3030
default: false
31+
workflow_call:
32+
inputs:
33+
environment:
34+
description: Deployment environment
35+
required: true
36+
type: string
37+
db_snapshot_arn:
38+
description: ARN of the DB snapshot to use (optional)
39+
required: false
40+
type: string
41+
egress_cidr:
42+
description: CIDR blocks to allow egress traffic.
43+
type: string
44+
required: true
45+
default: "[]"
46+
take_db_snapshot:
47+
description: Take a new DB snapshot before creating the environment
48+
type: boolean
49+
default: false
50+
skip_approval:
51+
description: Skip environment approval (auto-approve)
52+
type: boolean
53+
default: false
3154

3255
permissions: {}
3356

@@ -161,7 +184,7 @@ jobs:
161184
name: Notify on approval required
162185
runs-on: ubuntu-latest
163186
needs: plan
164-
if: ${{ inputs.environment == 'production' }}
187+
if: ${{ inputs.environment == 'production' && inputs.skip_approval == 'false' }}
165188
steps:
166189
- name: Notify pending approval
167190
if: inputs.environment == 'production'
@@ -187,7 +210,7 @@ jobs:
187210
name: Terraform apply
188211
runs-on: ubuntu-latest
189212
needs: plan
190-
environment: ${{ inputs.environment }}
213+
environment: ${{ inputs.skip_approval && null || inputs.environment }}
191214
permissions:
192215
id-token: write
193216
steps:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Scheduled Data Replication Refresh
2+
run-name: Nightly refresh of data replication environment
3+
4+
on:
5+
schedule:
6+
- cron: '0 2 * * *'
7+
8+
permissions: {}
9+
10+
jobs:
11+
refresh-data-replication:
12+
name: Refresh data replication
13+
uses: ./.github/workflows/refresh-data-replication.yml
14+
permissions:
15+
id-token: write
16+
with:
17+
environment: production
18+
egress_cidr: >-
19+
[
20+
"13.107.246.64/32", # GIAS
21+
"13.107.213.64/32", # GIAS
22+
"35.234.138.138/32", # PDS
23+
"52.178.45.139/32" # GIAS
24+
]
25+
take_db_snapshot: false
26+
skip_approval: true
27+
deploy-image:
28+
name: Deploy image
29+
needs: refresh-data-replication
30+
uses: ./.github/workflows/data-replication-pipeline.yml
31+
permissions:
32+
id-token: write
33+
with:
34+
environment: production
35+
git_ref_to_deploy: main
36+
skip_approval: true

0 commit comments

Comments
 (0)