From 973c2c021b78d8d69298fbe5fbf6bb3311ebd1c2 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Mon, 6 Jul 2026 18:43:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E7=BD=91=E7=BB=9C=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=8A=A0=E8=B6=85=E6=97=B6(runner=20=E9=95=BF=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=20~14min=20=E6=97=A0=E6=97=A5=E5=BF=97=E5=B4=A9?= =?UTF-8?q?=E6=BA=83=20=E2=86=92=20=E5=BF=AB=E5=A4=B1=E8=B4=A5=E5=8F=AF?= =?UTF-8?q?=E8=AF=8A=E6=96=AD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Setup Go 下载 + Forgejo GET/create/upload 的 curl 原本无 --max-time,网络停顿即 无限挂起(疑似 runner 长任务崩溃且不留日志的根因)。加 --max-time(+GET/下载 retry), 让停顿在超时内快失败并留下日志,而非静默 14 分钟后崩。POST 不 retry(避免重复建/传)。 Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u --- .gitea/workflows/deploy-server.yml | 3 ++- scripts/ci/lib-forgejo.sh | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/deploy-server.yml b/.gitea/workflows/deploy-server.yml index 91486d3..f2bc9d6 100644 --- a/.gitea/workflows/deploy-server.yml +++ b/.gitea/workflows/deploy-server.yml @@ -28,7 +28,8 @@ jobs: # 供应链完整性:校验 sha256(取自 Go 官方 release JSON,pin 为字面量), # 防镜像被篡改/MITM 注入恶意工具链(它会编译要上生产的二进制)。校验失败即中止。 GO_SHA256=42d4f7a32316aa66591eca7e89867256057a4264451aca10570a715b3637ba70 - curl -fsSL "https://golang.google.cn/dl/go${GO_VER}.linux-amd64.tar.gz" -o /tmp/go.tgz + curl -fsSL --max-time 180 --retry 3 --retry-delay 5 --retry-connrefused \ + "https://golang.google.cn/dl/go${GO_VER}.linux-amd64.tar.gz" -o /tmp/go.tgz echo "${GO_SHA256} /tmp/go.tgz" | sha256sum -c - rm -rf /usr/local/go tar -C /usr/local -xzf /tmp/go.tgz diff --git a/scripts/ci/lib-forgejo.sh b/scripts/ci/lib-forgejo.sh index b5cc19b..9e75cd6 100755 --- a/scripts/ci/lib-forgejo.sh +++ b/scripts/ci/lib-forgejo.sh @@ -43,7 +43,7 @@ forgejo_release_ensure() { get_code_file="/tmp/forgejo_get_code.$$" get_body_file="/tmp/forgejo_get_body.$$.json" - curl ${FORGEJO_CURL_TLS[@]+"${FORGEJO_CURL_TLS[@]}"} -s -o "$get_body_file" -w '%{http_code}' \ + curl ${FORGEJO_CURL_TLS[@]+"${FORGEJO_CURL_TLS[@]}"} -s --max-time 60 --retry 2 --retry-connrefused -o "$get_body_file" -w '%{http_code}' \ -H "Authorization: token ${FORGEJO_TOKEN}" \ "${FORGEJO_URL}/api/v1/repos/${FORGEJO_REPO}/releases/tags/${tag}" \ > "$get_code_file" @@ -83,7 +83,7 @@ json.dump( ) ' > "$create_req_file" - curl ${FORGEJO_CURL_TLS[@]+"${FORGEJO_CURL_TLS[@]}"} -s -o "$create_body_file" -w '%{http_code}' \ + curl ${FORGEJO_CURL_TLS[@]+"${FORGEJO_CURL_TLS[@]}"} -s --max-time 60 -o "$create_body_file" -w '%{http_code}' \ -X POST "${FORGEJO_URL}/api/v1/repos/${FORGEJO_REPO}/releases" \ -H "Authorization: token ${FORGEJO_TOKEN}" \ -H "Content-Type: application/json" \ @@ -127,7 +127,7 @@ forgejo_upload_asset() { code_file="/tmp/forgejo_upload_code.$$" body_file="/tmp/forgejo_upload_body.$$.json" - curl ${FORGEJO_CURL_TLS[@]+"${FORGEJO_CURL_TLS[@]}"} -s -o "$body_file" -w '%{http_code}' \ + curl ${FORGEJO_CURL_TLS[@]+"${FORGEJO_CURL_TLS[@]}"} -s --max-time 300 -o "$body_file" -w '%{http_code}' \ -X POST "${FORGEJO_URL}/api/v1/repos/${FORGEJO_REPO}/releases/${RELEASE_ID}/assets" \ -H "Authorization: token ${FORGEJO_TOKEN}" \ -F "attachment=@${file}" \