Skip to content

Commit 043b589

Browse files
committed
Incrementally testing GH action.
1 parent 4c3840c commit 043b589

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,23 @@ jobs:
1313
- name: Checkout code
1414
uses: actions/checkout@v4
1515

16-
- name: Authenticate to Google Cloud
16+
- name: Authenticate to Google Cloud PROD project
17+
id: gcloud_auth
18+
uses: google-github-actions/auth@v2
19+
with:
20+
credentials_json: ${{ secrets.PROD_GCP_MOBILITY_FEEDS_SA_KEY }}
21+
22+
- name: GCloud Setup
23+
uses: google-github-actions/setup-gcloud@v2
24+
25+
- name: Get PROD SQL service account
26+
run: |
27+
SOURCE_PROJECT_ID=${{ vars.PROD_MOBILITY_FEEDS_PROJECT_ID }}
28+
SERVICE_ACCOUNT=$(gcloud sql instances describe "mobilitydata-database-instance" --project=$SOURCE_PROJECT_ID --format="value(serviceAccountEmailAddress)")
29+
echo "SOURCE_SQL_SERVICE_ACCOUNT=$SERVICE_ACCOUNT" >> $GITHUB_ENV
30+
echo "Destination SQL Service Account: $SERVICE_ACCOUNT"
31+
32+
- name: Authenticate to Google Cloud QA project
1733
id: gcloud_auth
1834
uses: google-github-actions/auth@v2
1935
with:
@@ -24,7 +40,6 @@ jobs:
2440

2541
- name: Create DB dump bucket
2642
run: |
27-
SOURCE_PROJECT_ID=${{ vars.PROD_MOBILITY_FEEDS_PROJECT_ID }}
2843
DEST_PROJECT_ID=${{ vars.QA_MOBILITY_FEEDS_PROJECT_ID }}
2944
DUMP_BUCKET_NAME="mobilitydata-database-dump-qa"
3045
BUCKET_PROJECT_ID=${{ vars.QA_MOBILITY_FEEDS_PROJECT_ID }}
@@ -38,15 +53,11 @@ jobs:
3853
else
3954
echo "Bucket already exists."
4055
fi
41-
42-
# Get the service account got the PROD DB and give write permsssion to the bucket
43-
SOURCE_SQL_SERVICE_ACCOUNT=$(gcloud sql instances describe "mobilitydata-database-instance" --project=$SOURCE_PROJECT_ID --format="value(serviceAccountEmailAddress)")
44-
echo "Source SQL Service Account: $SOURCE_SQL_SERVICE_ACCOUNT"
4556
4657
# Give write permission for the source sql instance to write to the bucket
4758
gsutil iam ch serviceAccount:$SOURCE_SQL_SERVICE_ACCOUNT:objectCreator gs://$DUMP_BUCKET_NAME
4859
49-
# Get the service account got the QA DB and give read permsssion to the bucket
60+
# Get the service account for the QA DB and give read permsssion to the bucket
5061
DEST_SQL_SERVICE_ACCOUNT=$(gcloud sql instances describe $SQL_INSTANCE_NAME --project=DEST_PROJECT_ID --format="value(serviceAccountEmailAddress)")
5162
echo "Destination SQL Service Account: $DEST_SQL_SERVICE_ACCOUNT"
5263

0 commit comments

Comments
 (0)