-
Notifications
You must be signed in to change notification settings - Fork 9
30 lines (27 loc) · 1022 Bytes
/
sync-prd-acc-db.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
name: sync-prd-acc-db
on:
workflow_dispatch
concurrency: production_env
jobs:
deploy:
name: Sync databases - PRD to ACC
environment: acceptance
runs-on: ubuntu-22.04
env:
APP_DIR: '${HOME}/acc/app'
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_PORT: ${{ secrets.SSH_PORT }}
SSH_USER_WEB: ${{ secrets.SSH_USER_WEB }}
steps:
- name: Setup SSH key
run: |
mkdir -p ~/.ssh/
ssh-keyscan -H ${SSH_HOST} >> ~/.ssh/known_hosts
eval `ssh-agent -s`
echo "${SSH_KEY}" | tr -d '\r' | ssh-add -
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV
- name: Execute db sync prd -> acc
run: ssh ${SSH_USER_WEB}@${SSH_HOST} -p ${SSH_PORT} -o ServerAliveInterval=120 "pg_dump -F c ockovani_prd | pg_restore -c -d ockovani_acc"
- name: Execute migrations
run: ssh ${SSH_USER_WEB}@${SSH_HOST} -p ${SSH_PORT} "cd ${APP_DIR} && source venv/bin/activate && flask db upgrade"