fix: use curl tar.gz download instead of git clone
All checks were successful
Deploy to Server / deploy (push) Successful in 34s

This commit is contained in:
爽哒哒
2026-03-21 02:42:17 +08:00
parent cefd1aab58
commit 18740afdbd

View File

@@ -26,37 +26,25 @@ jobs:
echo -e "\n===== 停止并清理 Docker =====" echo -e "\n===== 停止并清理 Docker ====="
echo $SUDO_PASSWORD | sudo -S docker compose down echo $SUDO_PASSWORD | sudo -S docker compose down
# 3. 拉取 Git 最新代码 # 3. 拉取最新代码(用 curl 下载压缩包,避免 git 网络不稳定)
echo -e "\n===== 拉取 Git 代码 =====" echo -e "\n===== 拉取最新代码 ====="
REPO_URL="https://sdd:zsj981107@gitea.tangledup-ai.com/quant-speed-AI/Scoring-System.git" ARCHIVE_URL="https://sdd:zsj981107@gitea.tangledup-ai.com/quant-speed-AI/Scoring-System/archive/main.tar.gz"
if [ ! -d ".git" ]; then
echo "不是 git 仓库,尝试 clone最多重试3次..."
# 先清理可能残留的 .git
rm -rf .git
for i in 1 2 3; do for i in 1 2 3; do
echo "第 $i 次尝试 clone..." echo "第 $i 次尝试下载代码包..."
git clone --depth=1 $REPO_URL /tmp/scoring-system-clone && break curl -L --retry 3 --retry-delay 3 -o /tmp/scoring.tar.gz "$ARCHIVE_URL" && break
echo "clone 失败等待5秒后重试..." echo "下载失败等待5秒后重试..."
sleep 5 sleep 5
done done
if [ -d "/tmp/scoring-system-clone/.git" ]; then if [ ! -f /tmp/scoring.tar.gz ]; then
cp -r /tmp/scoring-system-clone/. . echo "错误:代码下载失败,终止部署"
rm -rf /tmp/scoring-system-clone
echo "clone 成功"
else
echo "错误clone 失败,终止部署"
rm -rf /tmp/scoring-system-clone
exit 1 exit 1
fi fi
else echo "解压代码..."
git remote set-url origin $REPO_URL tar -xzf /tmp/scoring.tar.gz -C /tmp/
if ! git pull; then # gitea 解压出来的目录名是 Scoring-System
echo "警告Git pull 失败,尝试强制同步远程代码..." rsync -av --exclude='.env' --exclude='media/' /tmp/Scoring-System/ $TARGET_DIR/
git fetch --all rm -rf /tmp/scoring.tar.gz /tmp/Scoring-System
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) echo "代码更新完成"
git reset --hard origin/$CURRENT_BRANCH
fi
fi
# 4. 创建/更新 .env 文件 # 4. 创建/更新 .env 文件
echo -e "\n===== 配置环境变量 =====" echo -e "\n===== 配置环境变量 ====="