修复sudo免密和目录问题
All checks were successful
Deploy to Server / deploy (push) Successful in 2s

This commit is contained in:
爽哒哒
2026-03-21 00:21:25 +08:00
parent adc272c8a9
commit 89c24af7ca

View File

@@ -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 <<EOF
sudo mkdir -p $TARGET_DIR/backend
cat > $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===== 操作完成!====="