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 platform/backend/requirements.txt pytest - name: Run Backend Quant Engine Tests run: pytest platform/backend/app/analytics/ || true - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '18' cache: 'npm' - name: Run Frontend Linting run: | cd platform/web npm install --legacy-peer-deps npm run lint || true 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" # 確保目錄存在 mkdir -p /opt/fifa2026/current cd /opt/fifa2026/current # 若不是 git repo 則初始化並綁定 if [ ! -d ".git" ]; then echo "Initializing git repository..." git init git remote add origin https://github.com/tsenyang/2026FIFAWorldCup.git || true git fetch origin git checkout -b main || true git reset --hard origin/main else git pull origin main fi # 使用 Docker Compose 重新建置並平滑重啟容器 docker-compose -f docker-compose.prod.yml up --build -d # 清理閒置的舊 Image 釋放伺服器空間 docker image prune -f echo "✅ [Deploy] Deployment completed successfully!"