Skip to content

add github actions

add github actions #1

Workflow file for this run

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