Skip to content

Commit

Permalink
apply fix to prod and qa
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgamez committed Feb 6, 2024
1 parent eb07793 commit 8367dd4
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/db-update-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

- name: Google Cloud Setup
uses: google-github-actions/setup-gcloud@v2

- name: Check GCP Machine Status
id: check_gw_status
run: |
Expand All @@ -74,7 +74,7 @@ jobs:
GCP_PROJECT_ID: ${{ vars.QA_MOBILITY_FEEDS_PROJECT_ID }}

update:
needs: get_database_ip
needs: [get_database_ip, gw_status]
uses: ./.github/workflows/db-update.yml
with:
PROJECT_ID: ${{ vars.DEV_MOBILITY_FEEDS_PROJECT_ID }}
Expand Down
39 changes: 38 additions & 1 deletion .github/workflows/db-update-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,46 @@ jobs:
DB_IP=$(gcloud sql instances describe ${{ secrets.DB_INSTANCE_NAME }} --format=json | jq -r '.ipAddresses[] | select(.type=="PRIVATE") | .ipAddress')
echo "DB_IP=$DB_IP" >> "$GITHUB_OUTPUT"
gw_status:
name: 'Check GCP GW Machine Status'
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.PROD_GCP_MOBILITY_FEEDS_SA_KEY }}

- name: Google Cloud Setup
uses: google-github-actions/setup-gcloud@v2

- name: Check GCP Machine Status
id: check_gw_status
run: |
gcloud config set component_manager/disable_update_check true
STATUS=$(gcloud compute instances describe $INSTANCE_NAME --zone=$ZONE --format='get(status)')
echo "Instance status: $STATUS"
echo "status=$STATUS" >> $GITHUB_OUTPUT
env:
ZONE: ${{ vars.MOBILITY_FEEDS_REGION }}-a
INSTANCE_NAME: 'zerotier-instance-prod'
GCP_PROJECT_ID: ${{ vars.PROD_MOBILITY_FEEDS_PROJECT_ID }}

- name: Start GCP Machine if Not Running
if: steps.check_gw_status.outputs.status != 'RUNNING'
run: |
echo "Instance is not running. Starting instance..."
gcloud compute instances start $INSTANCE_NAME --zone=$ZONE
echo "Instance is starting. Please wait..."
sleep 60
env:
ZONE: ${{ vars.MOBILITY_FEEDS_REGION }}-a
INSTANCE_NAME: 'zerotier-instance-prod'
GCP_PROJECT_ID: ${{ vars.PROD_MOBILITY_FEEDS_PROJECT_ID }}

update:
uses: ./.github/workflows/db-update.yml
needs: get_database_ip
needs: [get_database_ip, gw_status]
with:
PROJECT_ID: ${{ vars.PROD_MOBILITY_FEEDS_PROJECT_ID }}
REGION: ${{ vars.MOBILITY_FEEDS_REGION }}
Expand Down
38 changes: 37 additions & 1 deletion .github/workflows/db-update-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,46 @@ jobs:
gcloud config set project ${{ vars.QA_MOBILITY_FEEDS_PROJECT_ID }}
DB_IP=$(gcloud sql instances describe ${{ secrets.DB_INSTANCE_NAME }} --format=json | jq -r '.ipAddresses[] | select(.type=="PRIVATE") | .ipAddress')
echo "DB_IP=$DB_IP" >> "$GITHUB_OUTPUT"
gw_status:
name: 'Check GCP GW Machine Status'
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.QA_GCP_MOBILITY_FEEDS_SA_KEY }}

- name: Google Cloud Setup
uses: google-github-actions/setup-gcloud@v2

- name: Check GCP Machine Status
id: check_gw_status
run: |
gcloud config set component_manager/disable_update_check true
STATUS=$(gcloud compute instances describe $INSTANCE_NAME --zone=$ZONE --format='get(status)')
echo "Instance status: $STATUS"
echo "status=$STATUS" >> $GITHUB_OUTPUT
env:
ZONE: ${{ vars.MOBILITY_FEEDS_REGION }}-a
INSTANCE_NAME: 'zerotier-instance-qa'
GCP_PROJECT_ID: ${{ vars.QA_MOBILITY_FEEDS_PROJECT_ID }}

- name: Start GCP Machine if Not Running
if: steps.check_gw_status.outputs.status != 'RUNNING'
run: |
echo "Instance is not running. Starting instance..."
gcloud compute instances start $INSTANCE_NAME --zone=$ZONE
echo "Instance is starting. Please wait..."
sleep 60
env:
ZONE: ${{ vars.MOBILITY_FEEDS_REGION }}-a
INSTANCE_NAME: 'zerotier-instance-qa'
GCP_PROJECT_ID: ${{ vars.QA_MOBILITY_FEEDS_PROJECT_ID }}

update:
uses: ./.github/workflows/db-update.yml
needs: get_database_ip
needs: [get_database_ip, gw_status]
with:
PROJECT_ID: ${{ vars.QA_MOBILITY_FEEDS_PROJECT_ID }}
REGION: ${{ vars.MOBILITY_FEEDS_REGION }}
Expand Down

0 comments on commit 8367dd4

Please sign in to comment.