From 89c24af7ca8bcdf353ce49ae3fab750d34231b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=88=BD=E5=93=92=E5=93=92?= Date: Sat, 21 Mar 2026 00:21:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dsudo=E5=85=8D=E5=AF=86?= =?UTF-8?q?=E5=92=8C=E7=9B=AE=E5=BD=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/deploy.yaml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 5caed63..13f8267 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -11,14 +11,21 @@ jobs: host: 6.6.6.66 username: quant password: 123quant-speed + envs: SUDO_PASSWORD + envs_passwd: SUDO_PASSWORD script: | TARGET_DIR="/home/quant/scoring-system" REPO_URL="https://gitea.tangledup-ai.com/quant-speed-AI/Scoring-System.git" BRANCH="main" + SUDO_PASSWORD="123quant-speed" + + # 配置 sudo 免密 + echo "quant ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/quant # 1. 创建目标目录 echo "===== 创建目标目录: $TARGET_DIR =====" - mkdir -p $TARGET_DIR + sudo mkdir -p $TARGET_DIR + sudo chown -R quant:quant $TARGET_DIR # 2. 检查是否是 git 仓库 echo "===== 检查 git 仓库 =====" @@ -35,11 +42,12 @@ jobs: # 3. 停止并移除 Docker 容器 echo -e "\n===== 停止并清理 Docker =====" cd $TARGET_DIR - sudo docker compose down + sudo -n docker compose down 2>/dev/null || true # 4. 创建/更新 .env 文件 echo -e "\n===== 配置环境变量 =====" - cat > backend/.env < $TARGET_DIR/backend/.env <<'EOF' # Database Configuration DB_NAME=scoring DB_USER=quant-speed @@ -59,6 +67,7 @@ jobs: # 5. 重新启动 Docker 容器 echo -e "\n===== 启动 Docker 容器 =====" - sudo docker compose up -d --build + cd $TARGET_DIR + sudo -n docker compose up -d --build echo -e "\n===== 操作完成!====="