diff --git a/.gitea/workflows/mirror-to-gitee.yml b/.gitea/workflows/mirror-to-gitee.yml index 9da0bac..f077aaa 100644 --- a/.gitea/workflows/mirror-to-gitee.yml +++ b/.gitea/workflows/mirror-to-gitee.yml @@ -70,16 +70,26 @@ jobs: if git push --mirror "https://${DST_USER}:${DST_TOKEN}@${DST}" 2>&1; then echo "✅ 已同步到 Gitee" - # 推送后校验:远端 main 必须与本地一致,否则判定失败(避免“绿了但其实没推上去”) + # 推送后校验:远端 main 与 tag 集合必须与本地一致 + # (避免“绿了但其实没推上去” —— Gitee 限流时容易发生) LOCAL_MAIN=$(git rev-parse refs/heads/main 2>/dev/null || true) REMOTE_MAIN=$(git ls-remote "https://${DST_USER}:${DST_TOKEN}@${DST}" refs/heads/main | awk '{print $1}') + LOCAL_TAGS=$(git for-each-ref --format='%(refname:short)' refs/tags | sort | tr '\n' ' ') + REMOTE_TAGS=$(git ls-remote --tags "https://${DST_USER}:${DST_TOKEN}@${DST}" \ + | awk '{print $2}' | sed 's#refs/tags/##' | grep -v '\^{}$' | sort | tr '\n' ' ') echo "本地 main: ${LOCAL_MAIN:-<无>}" echo "远端 main: ${REMOTE_MAIN:-<无>}" + echo "本地 tag: ${LOCAL_TAGS:-<无>}" + echo "远端 tag: ${REMOTE_TAGS:-<无>}" if [ -n "$LOCAL_MAIN" ] && [ "$LOCAL_MAIN" != "$REMOTE_MAIN" ]; then echo "❌ 校验失败:远端 main 与本地不一致" exit 1 fi - echo "✅ 校验通过:Gitee 端 main 已对齐" + if [ "${LOCAL_TAGS% }" != "${REMOTE_TAGS% }" ]; then + echo "❌ 校验失败:远端 tag 与本地不一致" + exit 1 + fi + echo "✅ 校验通过:Gitee 端 main 与 tag 均已对齐" exit 0 fi wait_s=$((attempt * 30))