name: Deploy to Server on: [push] jobs: deploy: runs-on: ubuntu steps: - name: Deploy using SSH uses: https://gitea.com/actions/appleboy-ssh-action@v1.0.3 with: host: 6.6.6.66 username: quant password: 123quant-speed script: | TARGET_DIR="/home/quant/data/dev/deploy" SUDO_PASSWORD="123quant-speed" # 1. 切换到目标目录 echo "===== 切换到目标目录: $TARGET_DIR =====" cd $TARGET_DIR || { echo "错误:目录 $TARGET_DIR 不存在!" exit 1 } # 2. 停止并移除 Docker 容器 echo -e "\n===== 停止并清理 Docker =====" echo $SUDO_PASSWORD | sudo -S docker compose down # 3. 拉取最新代码 echo -e "\n===== 拉取最新代码 =====" REPO_URL="https://sdd:zsj981107@gitea.tangledup-ai.com/quant-speed-AI/Scoring-System.git" if [ ! -d ".git" ]; then echo "错误:目录不是 git 仓库,请先手动执行:" echo " cd $TARGET_DIR && git clone $REPO_URL ." exit 1 fi git remote set-url origin $REPO_URL git fetch origin main git reset --hard origin/main echo "代码更新完成" # 4. 创建/更新 .env 文件 echo -e "\n===== 配置环境变量 =====" cat > backend/.env <