-
-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (35 loc) · 1.24 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
44
45
46
47
48
49
50
51
name: Deploy
on: [push]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy via SSH
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
key: ${{ secrets.PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script: |
REPO_NAME="${{ secrets.REPO_NAME }}"
USERNAME="${{ secrets.USERNAME }}"
REPO_URL="git@github.com:$USERNAME/$REPO_NAME.git"
if [ ! -d "$REPO_NAME" ]; then
git clone "$REPO_URL" "$REPO_NAME"
fi
cd "$REPO_NAME"
if [ ! -d "venv_$REPO_NAME" ]; then
python3 -m venv "venv_$REPO_NAME"
fi
#if [ -f "$REPO_NAME.pid" ]; then
# kill -9 $(cat "$REPO_NAME.pid") || echo "No process found"
# rm "$REPO_NAME.pid"
#fi
git pull origin main
source "venv_$REPO_NAME/bin/activate"
pip install --upgrade pip
pip install -r requirements.txt
#nohup python main.py > output.log 2>&1 & echo $! > "$REPO_NAME.pid"