-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (37 loc) · 1.22 KB
/
deploy.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
# Github action for connecting to digitalocean server and run the deploy script
name: Deploy
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Connect to DigitalOcean Droplet
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
set -x
# kill the previous server
kill -9 $(cat ~/pc-components/backend/server_pid.txt)
kill -9 $(cat ~/pc-components/frontend/server_pid.txt)
set -e
cd ~
rm -rf ./pc-components
git clone https://github.com/Pansysk75/pc-components.git
cd ~/pc-components/backend
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
export DATABASE_URI=${{ secrets.DATABASE_URI }}
python3 run.py &> server_log.txt &
echo $! > server_pid.txt
cd ~/pc-components/frontend
python -m http.server 80 &> server_log.txt &
echo $! > server_pid.txt