75 lines
2.1 KiB
YAML
75 lines
2.1 KiB
YAML
name: 2026 World Cup Quant Platform - Production Deployment
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
test-and-lint:
|
|
name: Code Quality & Testing
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
cache: 'pip'
|
|
|
|
- name: Install Backend Dependencies
|
|
run: pip install -r backend/requirements.txt pytest
|
|
|
|
- name: Run Backend Quant Engine Tests
|
|
run: pytest backend/app/analytics/
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '18'
|
|
cache: 'npm'
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Run Frontend Linting
|
|
run: |
|
|
cd frontend
|
|
npm ci
|
|
npm run lint
|
|
|
|
deploy-docker:
|
|
name: Deploy to Production VM via Docker Compose
|
|
needs: test-and-lint
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/main'
|
|
|
|
steps:
|
|
- name: Deploy to Ubuntu Server via SSH
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.PROD_SERVER_IP }}
|
|
username: ${{ secrets.PROD_SERVER_USER }}
|
|
key: ${{ secrets.PROD_SSH_PRIVATE_KEY }}
|
|
script: |
|
|
echo "🚀 [Deploy] Starting deployment for 2026fifa.wooo.work"
|
|
|
|
# 進入專案目錄
|
|
cd /opt/worldcup-quant-2026
|
|
|
|
# 抓取最新程式碼
|
|
git pull origin main
|
|
|
|
# 使用 Docker Compose 重新建置並平滑重啟容器
|
|
# --build: 強制重新編譯 Dockerfile (前端靜態檔與後端依賴)
|
|
# -d: 背景執行
|
|
docker-compose -f docker-compose.prod.yml up --build -d
|
|
|
|
# 執行資料庫遷移 (若使用 Alembic)
|
|
# docker exec quant_backend alembic upgrade head
|
|
|
|
# 清理閒置的舊 Image 釋放伺服器空間
|
|
docker image prune -f
|
|
|
|
echo "✅ [Deploy] Deployment completed successfully!"
|