forked from civictechindex/brigade-project-index
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (51 loc) · 1.73 KB
/
publish-mysql.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
name: 'Publish: MySQL database'
on:
schedule:
# run every day at midnight
- cron: '0 0 1-31 * *'
workflow_dispatch:
env:
DB_HOST: 127.0.0.1
DB_USER: root
DB_PWD: ${{ secrets.MYSQL_PASSWORD }}
DB_DB: cfa_project_index
jobs:
publish-mysql:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- name: Set up connection to Kubernetes cluster
run: |
test -e ~/.kube || mkdir ~/.kube
echo "${{ secrets.MYSQL_KUBECONFIG_BASE64 }}" | base64 -d > ~/.kube/config
- name: Open port forwarding to MySQL
run: |
MYSQL_POD=$(kubectl get pod -l service=mysql -o jsonpath='{.items[0].metadata.name}')
kubectl port-forward "pods/$(kubectl get pod -l service=mysql -o jsonpath='{.items[0].metadata.name}')" 3306:3306 &
- name: Set up virtual env
run: |
cd tools/mysql-loader
python -m venv ".venv"
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
- name: Drop existing tables
run: mysql -h "${DB_HOST}" -u "${DB_USER}" -p"${DB_PWD}" < tools/mysql-loader/drop-schema.sql
- name: Create database tables
run: mysql -h "${DB_HOST}" -u "${DB_USER}" -p"${DB_PWD}" < tools/mysql-loader/create-schema.sql
- name: Load organizations
run: |
cd tools/mysql-loader
source .venv/bin/activate
python org-toml-2-mysql.py
- name: Load projects
run: |
cd tools/mysql-loader
source .venv/bin/activate
python proj-toml-2-mysql.py
# - uses: mxschmitt/action-tmate@v3
# if: failure()