mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-11-05 08:47:27 +00:00
Merge main into refactor/rename-batch6-site-docs:吸收前置检查重试脚本,GC_REPO 收为 job 级单一定义点
PR #19 合入后 main 上 ci.yml / release.yml 的前置检查换成了公共脚本 .github/scripts/check-gitcode-repo.sh,与本批「GC_REPO 收为单一定义点」 改了同一段代码,故冲突。解决口径: - 前置检查主体取 main 的重试脚本版本(不保留本批内联的那份长 case, 重试/退避/notfound-优先于-403 的能力保留) - GC_REPO 仍收为 job 级 env 单一定义处:main 上 ci.yml 两处、release.yml 三处字面量(含 upload_assets 调用里那处)全部改为走 ${GC_REPO} - 结果:每个文件内部只有 1 个定义点,注释里的实测清单同步为当前状态 零代码改动:.go/.lua/go.mod/go.sum/third_party 变更数 0。 YAML safe_load 两文件通过;check-gitcode-repo.sh bash -n 通过。
This commit is contained in:
58
.github/workflows/release.yml
vendored
58
.github/workflows/release.yml
vendored
@ -356,24 +356,21 @@ jobs:
|
||||
# ══════════════════════════════════════════════════════════════════
|
||||
# ★★ gitcode 镜像目标仓名 —— **本 job 的唯一定义处**。
|
||||
# 改 gitcode 仓名时只改这一行;下面所有消费点都走 ${GC_REPO}。
|
||||
# 与 ci.yml 的 sync-gitcode-main 保持同值(两个 workflow 各自独立
|
||||
# 定义:改的时候两个文件都要改,但每个文件内部只有一个定义处)。
|
||||
#
|
||||
# 取值依据(实测 2026-10-21 20:1x,直连不带代理,非推测):
|
||||
# $ curl -s -o /dev/null -w '%{http_code}' \
|
||||
# https://gitcode.com/JianFeeeee/<repo>
|
||||
#
|
||||
# 取值依据(实测 2026-10-21,直连不带代理,非推测):
|
||||
# https://gitcode.com/JianFeeeee/HologramAgent → 200 ← 当前用这个
|
||||
# https://gitcode.com/JianFeeeee/HomeAgent → 301 ← 旧名,跳转到上面
|
||||
# https://gitcode.com/JianFeeeee/homeagent-sdk → 200(SDK 仓,另一对象)
|
||||
# https://gitcode.com/JianFeeeee/hologramagentsdk → 200(SDK 仓,另一对象)
|
||||
# https://gitcode.com/JianFeeeee/homeagentsdk → 404
|
||||
# https://gitcode.com/JianFeeeee/HologramAgent-sdk → 404
|
||||
#
|
||||
# 背景:gitcode 侧镜像仓已由 HomeAgent 改名为 HologramAgent(与 GitHub
|
||||
# 主仓同名)。旧地址 HomeAgent 仍 301 跳转,跟随后也能到达,但走重定向
|
||||
# ⇒ 别再用它。下面几处消费点(ls-remote 探测、push tag、POST /releases、
|
||||
# upload_assets 的 GITCODE_REPO)全部走 ${GC_REPO},因此只改本行即可。
|
||||
# 主仓同名)。旧地址仍 301 跳转,跟随后也能到达,但走重定向 ⇒ 别再用它。
|
||||
# 判定两仓同一对象:两地址 git ls-remote 的 refs 列表 md5 相同。
|
||||
#
|
||||
# 以后再改名:只改这一行(+ ci.yml 与 upload_assets.py 各一行,共三个定义点)。
|
||||
# ⚠ 失败面(与 ci.yml 不同,别搞混):本 job 只红在镜像同步这一格,
|
||||
# GitHub 侧 release 产物此时已经发出去了;ci.yml 那个会红整条 main CI。
|
||||
# ══════════════════════════════════════════════════════════════════
|
||||
GC_REPO: JianFeeeee/HologramAgent
|
||||
steps:
|
||||
@ -396,46 +393,19 @@ jobs:
|
||||
# 改名(HomeAgent → HologramAgent)后 gitcode 目标仓需要**人工新建**,
|
||||
# 不探的话失败会埋在 push/curl 的原始输出里,看不出是「仓没建」。
|
||||
# 语义:token 未配 = 可选项跳过(上一步);token 有但仓不存在 = 硬失败。
|
||||
#
|
||||
# ★ 有界重试(与 ci.yml 的 sync-gitcode-main 同口径):只对**网络层**失败
|
||||
# 重试(3 次,退避 5s/10s);「仓不存在」与「凭据问题」**立即失败不重试**。
|
||||
# 两处逻辑落在同一个 .github/scripts/check-gitcode-repo.sh —— 不各写一份,
|
||||
# 因为两份「逐字一致」的脚本迟早会漂。
|
||||
- name: 前置检查 gitcode 目标仓是否存在
|
||||
if: steps.tok.outputs.ok == 'true'
|
||||
env:
|
||||
GC_TOKEN: ${{ secrets.GITCODE_TOKEN }}
|
||||
# GC_REPO 来自 job 级 env(唯一定义处),此处不重复字面量。
|
||||
run: |
|
||||
set -euo pipefail
|
||||
GC_URL="https://JianFeeeee:${GC_TOKEN}@gitcode.com"
|
||||
# GC_REPO 来自 job 级 env(唯一定义处),此处不重复字面量。
|
||||
if out=$(GIT_TERMINAL_PROMPT=0 git ls-remote --heads \
|
||||
"${GC_URL}/${GC_REPO}.git" 2>&1); then
|
||||
echo " 目标仓可访问:gitcode.com/${GC_REPO}"
|
||||
else
|
||||
# 日志脱敏:git 报错可能把 URL 的 userinfo(token 就在里面)带出来。
|
||||
# 先按 URL 结构遮 https://<userinfo>@ —— 与 token 内容无关,稳;
|
||||
# 再尽力遮一次字面量(token 含特殊字符时可能不生效,故只做兜底)。
|
||||
err=$(printf '%s\n' "$out" | sed -E 's#(https?://)[^@/[:space:]]*@#\1***@#g')
|
||||
err=$(printf '%s\n' "$err" | sed "s|${GC_TOKEN}|***|g" 2>/dev/null || printf '%s\n' "$err")
|
||||
case "$err" in
|
||||
# gitcode 真实报错(2026-10 实测):目标仓不存在时返回
|
||||
# remote: <CH.00905403> The project you were looking for could not be found.
|
||||
# fatal: ... The requested URL returned error: 403
|
||||
# 注意是 "could not be found" 与 403,不是 github 那种 "Repository not found"/404。
|
||||
*"could not be found"*|*"not found"*|*"Not Found"*|*"404"*|*"does not exist"*|*"does not appear to be a git repository"*)
|
||||
echo " ✗ gitcode 目标仓不存在:gitcode.com/${GC_REPO}"
|
||||
echo " 请先在该账号下创建镜像仓(只读镜像),再重跑本 job:"
|
||||
echo " https://gitcode.com/${GC_REPO}"
|
||||
;;
|
||||
*"403"*|*"401"*|*"Forbidden"*|*"Unauthorized"*)
|
||||
echo " ✗ 无法访问 gitcode 目标仓 gitcode.com/${GC_REPO}:仓不存在,或 token 无权访问"
|
||||
echo " 若仓已建,请确认 GITCODE_TOKEN 属于该仓的推送账号:"
|
||||
echo " https://gitcode.com/${GC_REPO}"
|
||||
;;
|
||||
*)
|
||||
echo " ✗ 无法访问 gitcode 目标仓 gitcode.com/${GC_REPO}(网络或凭据问题):"
|
||||
printf '%s\n' "$err" | sed 's/^/ /'
|
||||
;;
|
||||
esac
|
||||
# 显式失败 —— 不静默跳过,也不 echo 一句就当成功。
|
||||
exit 1
|
||||
fi
|
||||
bash .github/scripts/check-gitcode-repo.sh
|
||||
- name: 推 tag 与附件到 gitcode
|
||||
if: steps.tok.outputs.ok == 'true'
|
||||
env:
|
||||
|
||||
Reference in New Issue
Block a user