From 0d81c38fc6f1ea5ede3ad93bef89046a67e818e5 Mon Sep 17 00:00:00 2001 From: Lixi20 Date: Fri, 4 Sep 2026 18:13:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20CI=20=E7=A7=BB=E9=99=A4=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E5=A4=96=E9=83=A8=20action=20=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=EF=BC=8Ccheckout=20=E6=94=B9=E4=B8=BA=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E5=85=8B=E9=9A=86=E6=9C=AC=20Gitea=20=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Gitea 1.20+ 的 DEFAULT_ACTIONS_URL 仅接受 github/self,自定义 gitea.com 不生效, actions/checkout 回落 github.com 克隆(服务器不可达,实测 unexpected EOF) - checkout 改为 git init + 从 ${{ github.server_url }} 认证克隆(github.token), 与 apt 装 JDK 一起实现全链路零 GitHub 依赖 --- .gitea/workflows/ci.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 5dd0de4..550b0fa 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -6,9 +6,8 @@ # 2. 注册一个 act_runner,且 runner 所在主机具备: # - Docker(Testcontainers 需要,跑 postgres:18 一次性容器) # - 标签 ubuntu-latest 映射到含 bash/git 的镜像,或 host 模式执行 -# 3. 服务器无法访问 github.com:actions/* 本体经 app.ini 的 -# [actions].DEFAULT_ACTIONS_URL = https://gitea.com 拉取; -# JDK 用 apt 安装(见下方步骤),不依赖 GitHub 下载二进制。 +# 3. 服务器无法访问 github.com:本工作流不引用任何外部 action—— +# checkout 手动从本 Gitea 实例克隆,JDK 用 apt 安装,全链路无 GitHub 依赖。 # # 未启用 Actions 时本文件无副作用。 name: CI @@ -27,7 +26,16 @@ jobs: backend-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + # 不用 actions/checkout:Gitea 1.20+ 的 DEFAULT_ACTIONS_URL 仅接受 + # github/self,自定义镜像源不生效,action 会回落到 github.com(服务器不可达)。 + # 改为手动从本 Gitea 实例克隆,零外部依赖。 + - name: Checkout (manual) + run: | + git init -q . + AUTH_URL=$(echo "${{ github.server_url }}" | sed "s#https://#https://oauth2:${{ github.token }}@#") + git remote add origin "$AUTH_URL/${{ github.repository }}.git" + git fetch -q --depth 1 origin "+${{ github.ref }}:refs/ci-head" + git checkout -q refs/ci-head # 不用 actions/setup-java:它从 github.com 下载 JDK 二进制, # 服务器无法访问 GitHub(实测 ETIMEDOUT)。改用 apt 装 OpenJDK 17, # 并优先切换到腾讯云镜像源(runner 在腾讯云,内网加速)。