-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (34 loc) · 1.25 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
name: Deploy to Production Server
on:
push:
branches:
- main # 或者你希望触发部署的分支名称
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
password: ${{ secrets.SSH_PASSWORD }}
port: 22
script: |
# 更新系统包
sudo yum update -y
# 安装必要的软件包
sudo yum install -y epel-release
sudo yum install -y python3-pip supervisor
# 克隆最新的代码
git clone -b main [email protected]:shisongsong/xhm-server.git ~/apps/xhm-server/deployments/current
cd ~/apps/xhm-server/deployments/current
# 安装依赖
pip3 install -r requirements.txt
# 启动或重启 Gunicorn
echo "[program:app]" | sudo tee -a /etc/supervisord.d/app.conf
echo "command=gunicorn --workers 3 --bind unix:/tmp/app.sock -m app:app" | sudo tee -a /etc/supervisord.d/app.conf
sudo systemctl enable supervisord
sudo systemctl start supervisord
sudo systemctl restart supervisord