Skip to content

release-branch.yml 在 gh-pages 分支不存在时 bootstrap-fail (issue #3 Gap 3 / 独立) #5

Description

@libz-renlab-ai

release-branch.yml 在 gh-pages 分支不存在时 bootstrap-fail

现象

PR #2 合主分支后,release-branch.yml 首次端到端跑(commit 1c23fde)在 step 14「Publish latest.json to gh-pages」挂了:

+ git clone -q --branch gh-pages ...
fatal: Remote branch gh-pages not found in upstream origin
##[error]Process completed with exit code 128.

run 25905129718

根因

gh-pages 分支在本仓库从未被建过。release-branch.yml 假设它已存在,直接 git clone --branch gh-pages 来 update latest.json,不存在就 fail。

之前的 release runs(3cfbdb4 时也失败)说明这是一个长期存在的 bootstrap gap,只是 PR #2 之前没人盯过 release-branch 的成功率。

验证(本 PR 没引入这个 bug)

本 PR 在此 workflow 唯一改动是「在 publish job 开头加 early-exit 守门 + 给后续 12 个 step 加 if: steps.guard.outputs.skip != true」。守门本身工作正确(日志「latest.json 不存在(首次 release?) → 继续发布」),它说要继续 publish 是对的,挂在了下游不相关的 step 14。

修复方案

step 14 的 git clone --branch gh-pages 改成「先 fetch 试,失败则 orphan 建」:

TMPDIR=$(mktemp -d)
cd "$TMPDIR"
if git clone -q --depth=1 --branch gh-pages "https://x-access-token:${GH_TOKEN}@github.com/$GITHUB_REPOSITORY.git" .; then
  echo "gh-pages 已存在,fast-forward 写 latest.json"
else
  echo "gh-pages 不存在 → 初始化为 orphan"
  git clone -q --depth=1 "https://x-access-token:${GH_TOKEN}@github.com/$GITHUB_REPOSITORY.git" .
  git checkout --orphan gh-pages
  git rm -rf .
fi
# ... 后续 jq 写 latest.json + commit + push (已存在的逻辑)

或者更简单:在 release-branch.yml 单独加一个 prerequisite job「ensure-gh-pages-branch」,只在首次需要时跑。

优先级

关联


🤖 由 Claude Code 在 PR #2 合主分支后 release-branch.yml 首跑 dogfood 时发现

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions