Skip to content

🚀 Update API Database: zoning-api - dev #41

🚀 Update API Database: zoning-api - dev

🚀 Update API Database: zoning-api - dev #41

name: 🚀 Update API Database
run-name: "🚀 Update API Database: ${{ inputs.api_name }} - ${{ inputs.environment_name }}"
on:
workflow_dispatch:
inputs:
api_name:
description: "Which API database to update"
type: choice
required: true
options:
- zoning-api
environment_name:
description: "Which environemnt to use"
type: choice
required: true
options:
- dev
- staging
- production
jobs:
run_update:
name: Run Update
runs-on: macos-latest
environment:
name: ${{ inputs.environment_name }}
steps:
- uses: actions/checkout@v4
- name: Load Secrets
uses: 1password/load-secrets-action@v1
with:
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
TOY_SECRET_1PASSWORD: "op://AE Data Flow/Toy Secret File/TOY_SECRET_LABEL"
DO_SPACES_ENDPOINT: "op://AE Data Flow/Digital Ocean - S3 file storage/DO_SPACES_ENDPOINT"
DO_SPACES_ACCESS_KEY_ID: "op://AE Data Flow/Digital Ocean - S3 file storage/DO_SPACES_ACCESS_KEY"
DO_SPACES_SECRET_ACCESS_KEY: "op://AE Data Flow/Digital Ocean - S3 file storage/DO_SPACES_SECRET_KEY"
DO_SPACES_BUCKET_DISTRIBUTIONS: "op://AE Data Flow/Digital Ocean - S3 file storage/DO_SPACES_BUCKET_DISTRIBUTIONS"
DO_DATA_FLOW_DB_HOST: "op://AE Data Flow/Digital Ocean DB Cluster - AE Data Flow/host"
DO_DATA_FLOW_DB_PORT: "op://AE Data Flow/Digital Ocean DB Cluster - AE Data Flow/port"
DO_DATA_FLOW_DB_USERNAME_DEV: "op://AE Data Flow/Digital Ocean DB Cluster - AE Data Flow dev/username"
DO_DATA_FLOW_DB_PASSWORD_DEV: "op://AE Data Flow/Digital Ocean DB Cluster - AE Data Flow dev/password"
DO_DATA_FLOW_DB_DATABASE_DEV: "op://AE Data Flow/Digital Ocean DB Cluster - AE Data Flow dev/database"
DO_DATA_FLOW_DB_USERNAME_STAGING: "op://AE Data Flow/Digital Ocean DB Cluster - AE Data Flow staging/username"
DO_DATA_FLOW_DB_PASSWORD_STAGING: "op://AE Data Flow/Digital Ocean DB Cluster - AE Data Flow staging/password"
DO_DATA_FLOW_DB_DATASBASE_STAGING: "op://AE Data Flow/Digital Ocean DB Cluster - AE Data Flow staging/database"
DO_DATA_FLOW_DB_USERNAME_PRODUCTION: "op://AE Data Flow/Digital Ocean DB Cluster - AE Data Flow production/username"
DO_DATA_FLOW_DB_PASSWORD_PRODUCTION: "op://AE Data Flow/Digital Ocean DB Cluster - AE Data Flow production/password"
DO_DATA_FLOW_DB_DATASBASE_PRODUCTION: "op://AE Data Flow/Digital Ocean DB Cluster - AE Data Flow production/database"
DO_ZONING_API_DB_HOST: "op://AE Data Flow/Digital Ocean DB Cluster - Zoning API/host"
DO_ZONING_API_DB_PORT: "op://AE Data Flow/Digital Ocean DB Cluster - Zoning API/port"
DO_ZONING_API_DB_USERNAME_DEV: "op://AE Data Flow/Digital Ocean DB Cluster - Zoning API dev/username"
DO_ZONING_API_DB_PASSWORD_DEV: "op://AE Data Flow/Digital Ocean DB Cluster - Zoning API dev/password"
DO_ZONING_API_DB_DATABASE_DEV: "op://AE Data Flow/Digital Ocean DB Cluster - Zoning API dev/database"
- name: Set .env file
run: |
echo "DO_SPACES_ENDPOINT=$DO_SPACES_ENDPOINT" >> .env
echo "DO_SPACES_ACCESS_KEY=$DO_SPACES_ACCESS_KEY" >> .env
echo "DO_SPACES_SECRET_KEY=$DO_SPACES_SECRET_KEY" >> .env
echo "DO_SPACES_BUCKET_DISTRIBUTIONS=$DO_SPACES_BUCKET_DISTRIBUTIONS" >> .env
echo "BUILD_ENGINE_HOST=$DO_DATA_FLOW_DB_HOST" >> .env
echo "BUILD_ENGINE_PORT=$DO_DATA_FLOW_DB_PORT" >> .env
echo "ZONING_API_HOST=$DO_ZONING_API_DB_HOST" >> .env
echo "ZONING_API_PORT=$DO_ZONING_API_DB_PORT" >> .env
- name: Set .env file for dev
if: inputs.environment_name == 'dev'
run: |
echo "BUILD_ENGINE_USER=$DO_DATA_FLOW_DB_USERNAME_DEV" >> .env
echo "BUILD_ENGINE_PASSWORD=$DO_DATA_FLOW_DB_PASSWORD_DEV" >> .env
echo "BUILD_ENGINE_DB=$DO_DATA_FLOW_DB_DATABASE_DEV" >> .env
echo "ZONING_API_USER=$DO_ZONING_API_DB_USERNAME_DEV" >> .env
echo "ZONING_API_PASSWORD=$DO_ZONING_API_DB_PASSWORD_DEV" >> .env
echo "ZONING_API_DB=$DO_ZONING_API_DB_DATABASE_DEV" >> .env
- name: Set .env file for staging
if: inputs.environment_name == 'staging'
run: |
echo "BUILD_ENGINE_USER=$DO_DATA_FLOW_DB_USERNAME_STAGING" >> .env
echo "BUILD_ENGINE_PASSWORD=$DO_DATA_FLOW_DB_PASSWORD_STAGING" >> .env
echo "BUILD_ENGINE_DB=$DO_DATA_FLOW_DB_DATASBASE_STAGING" >> .env
- name: Set .env file for production
if: inputs.environment_name == 'production'
run: |
echo "BUILD_ENGINE_USER=$DO_DATA_FLOW_DB_USERNAME_PRODUCTION" >> .env
echo "BUILD_ENGINE_PASSWORD=$DO_DATA_FLOW_DB_PASSWORD_PRODUCTION" >> .env
echo "BUILD_ENGINE_DB=$DO_DATA_FLOW_DB_DATASBASE_PRODUCTION" >> .env
- name: Setup python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Setup PostgreSQL
uses: tj-actions/install-postgresql@v3
with:
postgresql-version: 15
- name: Health check
run: |
python --version
echo "Hello API Database update!"
echo "Using API Database: ${{ inputs.api_name }}"
echo "Using environment: ${{ inputs.environment_name }}"
echo "Toy Secret value: $TOY_SECRET_1PASSWORD"
- name: Install dependencies
run: |
brew install minio/stable/mc
mc alias set spaces $DO_SPACES_ENDPOINT $DO_SPACES_ACCESS_KEY_ID $DO_SPACES_SECRET_ACCESS_KEY
python3 -m pip install --force-reinstall -r requirements.txt
postgres --version
psql --version
pg_dump --version
which psql
pip list
dbt deps
- name: Download
run: |
./bash/download.sh
- name: Import
run: |
./bash/import.sh
- name: Transform
run: |
./bash/transform.sh
- name: Export to API DB
run: |
./bash/export.sh