-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove zerotier dependency on db connection (#305)
- Loading branch information
1 parent
b6f7508
commit 541504c
Showing
6 changed files
with
220 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,9 @@ on: | |
GCP_MOBILITY_FEEDS_SA_KEY: | ||
description: Service account key | ||
required: true | ||
DB_GCP_MOBILITY_FEEDS_SA_KEY: | ||
description: Service account key where the DB in deployed | ||
required: true | ||
DB_USER_NAME: | ||
description: PostgreSQL User Name | ||
required: true | ||
|
@@ -37,6 +40,9 @@ on: | |
OP_SERVICE_ACCOUNT_TOKEN: | ||
description: OnePassword Service Account Token | ||
required: true | ||
POSTGRE_SQL_INSTANCE_NAME: | ||
description: PostgreSQL Instance Name | ||
required: true | ||
inputs: | ||
PROJECT_ID: | ||
description: GCP Project ID | ||
|
@@ -50,14 +56,10 @@ on: | |
description: GCP ENVIRONMENT | ||
required: true | ||
type: string | ||
DB_IP: | ||
description: Database IP Address | ||
required: true | ||
type: string | ||
ZEROTIER_NETWORK_GW_KEY: | ||
description: ZeroTier Network Gateway | ||
type: string | ||
DB_ENVIRONMENT: | ||
description: GCP ENVIRONMENT where DB is deployed. | ||
required: true | ||
type: string | ||
REGION: | ||
description: GCP region | ||
required: true | ||
|
@@ -71,29 +73,30 @@ jobs: | |
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Authenticate to Google Cloud QA/PROD | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
credentials_json: ${{ secrets.DB_GCP_MOBILITY_FEEDS_SA_KEY }} | ||
|
||
- name: Google Cloud Setup | ||
uses: google-github-actions/setup-gcloud@v2 | ||
|
||
- name: Load secrets from 1Password | ||
uses: 1password/[email protected] | ||
with: | ||
export-env: true # Export loaded secrets as environment variables | ||
env: | ||
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | ||
GCP_FEED_ZEROTIER_NETWORK_ID: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/4c7ut35delweauflq7g2kphl5u/credential" | ||
GCP_FEED_ZEROTIER_TOKEN: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/4lsfgxbtegqicjj2fz6skkj2pm/credential" | ||
GCP_FEED_ZEROTIER_SSH_KEY: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/h4zgaa7wyk3ml3mrggedezyxkm/private key" | ||
GCP_FEED_ZEROTIER_NETWORK_GW: ${{ inputs.ZEROTIER_NETWORK_GW_KEY }} | ||
|
||
- name: ZeroTier | ||
uses: zerotier/github-action@v1 | ||
with: | ||
network_id: ${{ env.GCP_FEED_ZEROTIER_NETWORK_ID }} | ||
auth_token: ${{ env.GCP_FEED_ZEROTIER_TOKEN }} | ||
|
||
GCP_FEED_SSH_USER: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_SSH_USER/username" | ||
GCP_FEED_BASTION_NAME: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_BASTION_NAME/username" | ||
GCP_FEED_BASTION_SSH_KEY: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_BASTION_SSH_KEY/private key" | ||
|
||
- name: Tunnel | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ env.GCP_FEED_ZEROTIER_SSH_KEY }}" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
ssh -o StrictHostKeyChecking=no -L 5432:${{ inputs.DB_IP }}:5432 it@${{ env.GCP_FEED_ZEROTIER_NETWORK_GW }} -N & | ||
echo "${{ env.GCP_FEED_BASTION_SSH_KEY }}" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
./scripts/tunnel-create.sh -project_id ${{ inputs.PROJECT_ID }} -zone ${{ inputs.REGION }}-a -instance ${{ env.GCP_FEED_BASTION_NAME }}-${{ inputs.DB_ENVIRONMENT}} -target_account ${{ env.GCP_FEED_SSH_USER }} -db_instance ${{ secrets.POSTGRE_SQL_INSTANCE_NAME }} | ||
sleep 10 # Wait for the tunnel to establish | ||
# Uncomment the following block to test the database connection through the tunnel | ||
|
@@ -135,6 +138,14 @@ jobs: | |
with: | ||
python-version: '3.10' | ||
|
||
- name: Authenticate to Google Cloud QA/PROD | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
credentials_json: ${{ secrets.DB_GCP_MOBILITY_FEEDS_SA_KEY }} | ||
|
||
- name: Google Cloud Setup | ||
uses: google-github-actions/setup-gcloud@v2 | ||
|
||
- name: Update .env file | ||
run: | | ||
echo "PGUSER=${{ secrets.DB_USER_NAME }}" > config/.env.local | ||
|
@@ -153,24 +164,17 @@ jobs: | |
export-env: true # Export loaded secrets as environment variables | ||
env: | ||
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | ||
GCP_FEED_ZEROTIER_NETWORK_ID: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/4c7ut35delweauflq7g2kphl5u/credential" | ||
GCP_FEED_ZEROTIER_TOKEN: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/4lsfgxbtegqicjj2fz6skkj2pm/credential" | ||
GCP_FEED_ZEROTIER_SSH_KEY: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/h4zgaa7wyk3ml3mrggedezyxkm/private key" | ||
GCP_FEED_ZEROTIER_NETWORK_GW: ${{ inputs.ZEROTIER_NETWORK_GW_KEY }} | ||
|
||
- name: ZeroTier | ||
uses: zerotier/github-action@v1 | ||
with: | ||
network_id: ${{ env.GCP_FEED_ZEROTIER_NETWORK_ID }} | ||
auth_token: ${{ env.GCP_FEED_ZEROTIER_TOKEN }} | ||
|
||
GCP_FEED_SSH_USER: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_SSH_USER/username" | ||
GCP_FEED_BASTION_NAME: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_BASTION_NAME/username" | ||
GCP_FEED_BASTION_SSH_KEY: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GCP_FEED_BASTION_SSH_KEY/private key" | ||
|
||
- name: Tunnel | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ env.GCP_FEED_ZEROTIER_SSH_KEY }}" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
ssh -o StrictHostKeyChecking=no -L 5432:${{ inputs.DB_IP }}:5432 it@${{ env.GCP_FEED_ZEROTIER_NETWORK_GW }} -N & | ||
sleep 10 # Wait for the tunnel to establish | ||
echo "${{ env.GCP_FEED_BASTION_SSH_KEY }}" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
./scripts/tunnel-create.sh -project_id ${{ inputs.PROJECT_ID }} -zone ${{ inputs.REGION }}-a -instance ${{ env.GCP_FEED_BASTION_NAME }}-${{ inputs.DB_ENVIRONMENT}} -target_account ${{ env.GCP_FEED_SSH_USER }} -db_instance ${{ secrets.POSTGRE_SQL_INSTANCE_NAME }} | ||
sleep 10 # Wait for the tunnel to establish | ||
- name: Install requirements and generate db model | ||
run: scripts/db-gen.sh | ||
|
Oops, something went wrong.