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 代码 ====="
|
echo -e "\n===== 拉取 Git 代码 ====="
|
||||||
REPO_URL="https://sdd:zsj981107@gitea.tangledup-ai.com/quant-speed-AI/Scoring-System.git"
|
REPO_URL="https://sdd:zsj981107@gitea.tangledup-ai.com/quant-speed-AI/Scoring-System.git"
|
||||||
if [ ! -d ".git" ]; then
|
if [ ! -d ".git" ]; then
|
||||||
echo "不是 git 仓库,初始化并拉取代码..."
|
echo "不是 git 仓库,尝试 clone(最多重试3次)..."
|
||||||
git init
|
# 先清理可能残留的 .git
|
||||||
git remote add origin $REPO_URL
|
rm -rf .git
|
||||||
git fetch origin
|
for i in 1 2 3; do
|
||||||
git checkout -b main origin/main
|
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
|
else
|
||||||
git remote set-url origin $REPO_URL
|
git remote set-url origin $REPO_URL
|
||||||
if ! git pull; then
|
if ! git pull; then
|
||||||
|
|||||||
Reference in New Issue
Block a user