fix: use git clone with retry for initial deploy
All checks were successful
Deploy to Server / deploy (push) Successful in 20s
All checks were successful
Deploy to Server / deploy (push) Successful in 20s
This commit is contained in:
@@ -30,11 +30,24 @@ jobs:
|
||||
echo -e "\n===== 拉取 Git 代码 ====="
|
||||
REPO_URL="https://sdd:zsj981107@gitea.tangledup-ai.com/quant-speed-AI/Scoring-System.git"
|
||||
if [ ! -d ".git" ]; then
|
||||
echo "不是 git 仓库,初始化并拉取代码..."
|
||||
git init
|
||||
git remote add origin $REPO_URL
|
||||
git fetch origin
|
||||
git checkout -b main origin/main
|
||||
echo "不是 git 仓库,尝试 clone(最多重试3次)..."
|
||||
# 先清理可能残留的 .git
|
||||
rm -rf .git
|
||||
for i in 1 2 3; do
|
||||
echo "第 $i 次尝试 clone..."
|
||||
git clone --depth=1 $REPO_URL /tmp/scoring-system-clone && break
|
||||
echo "clone 失败,等待5秒后重试..."
|
||||
sleep 5
|
||||
done
|
||||
if [ -d "/tmp/scoring-system-clone/.git" ]; then
|
||||
cp -r /tmp/scoring-system-clone/. .
|
||||
rm -rf /tmp/scoring-system-clone
|
||||
echo "clone 成功"
|
||||
else
|
||||
echo "错误:clone 失败,终止部署"
|
||||
rm -rf /tmp/scoring-system-clone
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
git remote set-url origin $REPO_URL
|
||||
if ! git pull; then
|
||||
|
||||
Reference in New Issue
Block a user