File tree Expand file tree Collapse file tree 4 files changed +23
-3
lines changed
scripts/duplicate-prod-db Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 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
1416jobs :
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
Original file line number Diff line number Diff line change 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
710REQUIRED_VARS=(
811 " DB_INSTANCE_NAME"
Original file line number Diff line number Diff line change 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
710REQUIRED_VARS=(
811 " DEST_PROJECT_ID"
Original file line number Diff line number Diff line change 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
711REQUIRED_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+
1830echo " Tunelling"
1931mkdir -p ~ /.ssh
2032echo " $GCP_FEED_BASTION_SSH_KEY " > ~ /.ssh/id_rsa
You can’t perform that action at this time.
0 commit comments