Skip to content

Commit

Permalink
add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
shisongsong committed Jul 26, 2024
1 parent f0c2151 commit 617925f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ wtforms
Flask-Login
flask-marshmallow
marshmallow-sqlalchemy
flask_cors
flask_cors
gunicorn

0 comments on commit 617925f

Please sign in to comment.