Skip to content

Commit 98963f1

Browse files
committed
ci: Gitee 镜像失败自动重试 3 次(Gitee 偶发连接超时)
1 parent cf608d7 commit 98963f1

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎.github/workflows/gitee-mirror.yml‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,19 @@ jobs:
2929
git remote add gitee "https://gitee.com/${GITEE_REPO}.git"
3030
git config --local "http.https://gitee.com/.extraheader" \
3131
"Authorization: Basic $(printf 'thousand-code-crafts:%s' "$GITEE_TOKEN" | base64 -w0)"
32-
git push --prune gitee "+refs/heads/*:refs/heads/*" "+refs/tags/*:refs/tags/*"
33-
echo "镜像完成:$(git rev-parse --short HEAD) → gitee.com/${GITEE_REPO}"
32+
# Gitee 偶发连接超时(>300s),自动重试 3 次兜底
33+
for attempt in 1 2 3; do
34+
echo "::group::镜像尝试第 $attempt 次"
35+
if git push --prune gitee "+refs/heads/*:refs/heads/*" "+refs/tags/*:refs/tags/*"; then
36+
echo "::endgroup::"
37+
echo "镜像完成:$(git rev-parse --short HEAD) → gitee.com/${GITEE_REPO}"
38+
exit 0
39+
fi
40+
echo "::endgroup::"
41+
if [ "$attempt" -eq 3 ]; then
42+
echo "::error::镜像 3 次尝试均失败"
43+
exit 1
44+
fi
45+
echo "::warning::第 $attempt 次镜像失败,$((attempt * 30))s 后重试"
46+
sleep $((attempt * 30))
47+
done

0 commit comments

Comments
 (0)