-
Notifications
You must be signed in to change notification settings - Fork 2
34 lines (32 loc) · 1.21 KB
/
resetDatabase.yml
File metadata and controls
34 lines (32 loc) · 1.21 KB
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
name: resetDatabse
on:
workflow_dispatch:
inputs:
alembic:
description: 'Use Alembic to upgrade database'
required: true
default: true
type: boolean
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >>$GITHUB_OUTPUT
id: extract_branch
- uses: actions/checkout@v3
- name: Push to server
if: ${{ steps.teamAffiliation.outputs.isTeamMember == true }}
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
sudo systemctl stop Backend.${{ steps.extract_branch.outputs.branch }}
cd ${{ secrets.PROJECT_PATH }}/${{ steps.extract_branch.outputs.branch }}
psql -d test -c "DROP DATABASE backend_${{ steps.extract_branch.outputs.branch }};"
psql -d test -c "CREATE DATABASE backend_${{ steps.extract_branch.outputs.branch }};"
alembic upgrade head
sudo systemctl start Backend.${{ steps.extract_branch.outputs.branch }}