Skip to content

Commit da2f19c

Browse files
authored
feat: Triggered the copy DB GH action by a pre-release trigger.
1 parent f6a4e1a commit da2f19c

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

.github/workflows/duplicate-prod-db.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ on:
99
backup_db:
1010
description: 'Backup the current QA DB before importing the dump'
1111
required: false
12-
default: 'true'
12+
default: 'false'
13+
release:
14+
types: [ prereleased ]
1315

1416
jobs:
1517
run-script:
@@ -24,11 +26,11 @@ jobs:
2426
DEST_DATABASE_PASSWORD: ${{ secrets.QA_POSTGRE_USER_PASSWORD }}
2527
DUMP_FILE_NAME: "prod-db-dump.sql"
2628
SOURCE_DATABASE_NAME: ${{ vars.PROD_POSTGRE_SQL_DB_NAME }}
27-
DEST_DATABASE_NAME: ${{ inputs.dest_database_name || 'MobilityDatabaseProdDuplicate' }}
29+
DEST_DATABASE_NAME: ${{ inputs.dest_database_name || 'MobilityDatabase' }}
2830
DEST_DATABASE_USER: ${{ secrets.QA_POSTGRE_USER_NAME }}
2931
DEST_DATABASE_IMPORT_USER: ${{ secrets.PROD_POSTGRE_USER_NAME }}
3032
GCP_FEED_BASTION_SSH_KEY: ${{ secrets.GCP_FEED_BASTION_SSH_KEY }}
31-
BACKUP_DB: ${{ inputs.backup_db || 'true' }}
33+
BACKUP_DB: ${{ inputs.backup_db || 'false' }}
3234

3335
steps:
3436
- name: Checkout code

scripts/duplicate-prod-db/copy-prod-db-to-qa.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# It exports the PROD DB to a bucket, then imports it to the QA DB.
44
# It also makes a backup of the QA DB.
55

6+
# Exit on any error
7+
set -e
8+
69
# Validate required environment variables
710
REQUIRED_VARS=(
811
"DB_INSTANCE_NAME"

scripts/duplicate-prod-db/create-dump-bucket.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# It creates a bucket to house the dump of the production database.
44
# It also gives permission to the dump bucket so the SQL instances in PROD and QA can use it.
55

6+
# Exit on any error
7+
set -e
8+
69
# Validate required environment variables
710
REQUIRED_VARS=(
811
"DEST_PROJECT_ID"

scripts/duplicate-prod-db/post-import.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# - Give permission to the tables to the postgres user.
55
# - Modify the email addresses in the DB so we can't accidentally email real people.
66

7+
# Exit on any error
8+
set -e
9+
10+
# Validate required environment variables
711
REQUIRED_VARS=(
812
"GCP_FEED_BASTION_SSH_KEY"
913
"DEST_PROJECT_ID"
@@ -15,6 +19,14 @@ REQUIRED_VARS=(
1519
"DEST_DATABASE_IMPORT_USER"
1620
"DEST_DATABASE_NAME"
1721
)
22+
23+
for VAR in "${REQUIRED_VARS[@]}"; do
24+
if [ -z "${!VAR}" ]; then
25+
echo "Error: Environment variable $VAR is not set."
26+
exit 1
27+
fi
28+
done
29+
1830
echo "Tunelling"
1931
mkdir -p ~/.ssh
2032
echo "$GCP_FEED_BASTION_SSH_KEY" > ~/.ssh/id_rsa

0 commit comments

Comments
 (0)