[0.2.7.4][ci]
Some checks failed
CI / docker-ci (push) Failing after 3s

This commit is contained in:
2026-03-18 20:44:05 +08:00
parent 24d5caef5a
commit 61d2189f21

View File

@@ -56,21 +56,29 @@ jobs:
cd "$GITHUB_WORKSPACE" cd "$GITHUB_WORKSPACE"
git init . git init .
# 优先使用 secrets.token (USER_TOKEN),因为 secrets.GITHUB_TOKEN 在某些 Gitea 配置下可能权限受限 # 优先使用 secrets.token (USER_TOKEN)
AUTH_TOKEN="$TOKEN" AUTH_TOKEN="$TOKEN"
USE_BASIC_AUTH="false"
if [ -n "$USER_TOKEN" ]; then if [ -n "$USER_TOKEN" ]; then
AUTH_TOKEN="$USER_TOKEN" AUTH_TOKEN="$USER_TOKEN"
echo "Using secrets.token for authentication." USE_BASIC_AUTH="true"
echo "Using secrets.token for authentication (Basic Auth)."
elif [ -n "$TOKEN" ]; then elif [ -n "$TOKEN" ]; then
echo "Using secrets.GITHUB_TOKEN for authentication." echo "Using secrets.GITHUB_TOKEN for authentication (Bearer Header)."
else else
echo "Warning: No token found. Attempting unauthenticated fetch (will fail for private repos)." echo "Warning: No token found. Attempting unauthenticated fetch (will fail for private repos)."
fi fi
if [ -z "$AUTH_TOKEN" ]; then if [ -z "$AUTH_TOKEN" ]; then
git fetch --depth=1 "$SERVER/$REPO.git" "$REF" git fetch --depth=1 "$SERVER/$REPO.git" "$REF"
elif [ "$USE_BASIC_AUTH" = "true" ]; then
# 使用 Basic Auth: https://token:x-oauth-basic@gitea.com/user/repo.git
# 去掉 SERVER 中的 https:// 或 http:// 前缀以构建正确的 URL
CLEAN_SERVER=$(echo "$SERVER" | sed -E 's/^\s*.*:\/\///g')
git fetch --depth=1 "https://$AUTH_TOKEN:x-oauth-basic@$CLEAN_SERVER/$REPO.git" "$REF"
else else
# 使用 Bearer Token 进行认证 # 使用 Bearer Token 进行认证 (GITHUB_TOKEN)
git -c http.extraHeader="Authorization: Bearer $AUTH_TOKEN" fetch --depth=1 "$SERVER/$REPO.git" "$REF" git -c http.extraHeader="Authorization: Bearer $AUTH_TOKEN" fetch --depth=1 "$SERVER/$REPO.git" "$REF"
fi fi
git checkout FETCH_HEAD git checkout FETCH_HEAD