This commit is contained in:
@@ -15,14 +15,27 @@ jobs:
|
||||
# 清理工作目录
|
||||
ls -A1 | xargs rm -rf
|
||||
|
||||
# 使用 Gitea 提供的 Token 直接克隆
|
||||
# 注意:gitea.repository_clone_url 通常是 http://domain/user/repo.git
|
||||
# 我们在 clone 命令中手动注入用户名和 token
|
||||
# 调试信息: 打印一下基本的变量 (注意不要打印 token)
|
||||
echo "Server: ${{ gitea.server_url }}"
|
||||
echo "Repo: ${{ gitea.repository }}"
|
||||
echo "Actor: ${{ gitea.actor }}"
|
||||
|
||||
CLONE_URL=$(echo "${{ gitea.repository_clone_url }}" | sed -e "s|://|://${{ gitea.actor }}:${{ gitea.token }}@|")
|
||||
# 既然 clone_url 可能是空的,我们手动拼接
|
||||
# 1. 去掉 server_url 的协议头 (http:// 或 https://)
|
||||
SERVER_DOMAIN=$(echo "${{ gitea.server_url }}" | sed -E 's|https?://||')
|
||||
|
||||
echo "Cloning from local Gitea..."
|
||||
git clone --depth 1 "$CLONE_URL" .
|
||||
# 2. 判断使用 http 还是 https
|
||||
PROTO="http"
|
||||
if [[ "${{ gitea.server_url }}" == https* ]]; then
|
||||
PROTO="https"
|
||||
fi
|
||||
|
||||
# 3. 拼接完整 URL: proto://user:token@domain/repo.git
|
||||
GIT_URL="${PROTO}://${{ gitea.actor }}:${{ gitea.token }}@${SERVER_DOMAIN}/${{ gitea.repository }}.git"
|
||||
|
||||
echo "Cloning from ${PROTO}://${SERVER_DOMAIN}/${{ gitea.repository }}.git ..."
|
||||
|
||||
git clone --depth 1 "$GIT_URL" .
|
||||
git log -1 --format='%h - %s'
|
||||
|
||||
# 2. 登录镜像仓库 (如果有配置)
|
||||
|
||||
Reference in New Issue
Block a user