File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020 SOURCE_DATABASE_NAME : ${{ vars.PROD_POSTGRE_SQL_DB_NAME }}
2121 DEST_DATABASE_NAME : " testDB"
2222 DEST_DATABASE_USER : ${{ secrets.QA_POSTGRE_USER_NAME }}
23+ GCP_FEED_BASTION_SSH_KEY : ${{ secrets.GCP_FEED_BASTION_SSH_KEY }}
2324
2425
2526 steps :
@@ -110,3 +111,25 @@ jobs:
110111
111112 export PGPASSWORD=$DEST_DATABASE_PASSWORD
112113 gcloud sql import sql $DB_INSTANCE_NAME gs://$DUMP_BUCKET_NAME/$DUMP_FILE_NAME --database=$DEST_DATABASE_NAME --user=$DEST_DATABASE_USER --quiet
114+
115+ - name : Load secrets from 1Password
116+ uses : 1password/load-secrets-action@v2.0.0
117+ with :
118+ export-env : true # Export loaded secrets as environment variables
119+ env :
120+ OP_SERVICE_ACCOUNT_TOKEN : ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
121+ GCP_FEED_SSH_USER : " op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_SSH_USER/username"
122+ GCP_FEED_BASTION_NAME : " op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_BASTION_NAME/username"
123+ GCP_FEED_BASTION_SSH_KEY : " op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_BASTION_SSH_KEY/private key"
124+
125+ - name : Tunnel
126+ run : |
127+ mkdir -p ~/.ssh
128+ echo "${{ env.GCP_FEED_BASTION_SSH_KEY }}" > ~/.ssh/id_rsa
129+ chmod 600 ~/.ssh/id_rsa
130+ ./scripts/tunnel-create.sh -project_id $DEST_PROJECT_ID -zone ${GCP_REGION}-a -instance ${GCP_FEED_BASTION_NAME}-qa -target_account ${GCP_FEED_SSH_USER} -db_instance ${DB_INSTANCE_NAME} -port 5454
131+ sleep 10 # Wait for the tunnel to establish
132+
133+ export PGPASSWORD=$DEST_DATABASE_PASSWORD
134+ psql -h localhost -p 5454 -U data_feeds_user -d $DEST_DATABASE_NAME -c "select count(*) from feed;"
135+
You can’t perform that action at this time.
0 commit comments