-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (111 loc) · 5.94 KB
/
update_api_database.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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: 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 uninstall postgresql@14
brew install postgresql@15
export PATH="/usr/local/opt/postgresql@15/bin:$PATH"
brew services start postgresql@15
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
- name: Check dependencies (PATH really)
run: |
which psql