Compare commits

5 Commits

Author SHA1 Message Date
c5721d84ed 依赖加上gunicorn 2025-02-15 16:25:33 +08:00
5bf53beef3 采用deepseek的部署脚本 2025-02-10 23:10:49 +08:00
353f1f4ffd 使用pipreqs生成 requirements.txt 2025-02-10 22:36:45 +08:00
f83b295cdf 生成pip freeze > requirements.txt 2025-02-10 22:32:55 +08:00
1c5fed5f7d 部署脚本 2025-02-10 22:06:49 +08:00
2 changed files with 38 additions and 0 deletions

36
.github/workflows/deploy.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: Deploy Django
on:
push:
branches: [ main ] # 触发分支
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: python manage.py test
- name: Deploy to Server
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /var/www/your_project
git pull origin main
source venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py collectstatic --noinput
sudo systemctl restart gunicorn
sudo systemctl reload nginx

2
requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
Django==4.2
gunicorn==20.1.0