From af3ec32722fe4c4027de66a5ae42634bb87f6b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=95=86=E6=98=8A=E6=9A=98521021910816?= Date: Sun, 9 Aug 2026 22:16:34 +0800 Subject: [PATCH] fix: keep a build alive when the job branch moves under it Publishing the running state pushed once and failed the whole build if the branch had moved, which is how a healthy run died: the web app wrote a verdict to the same branch while the runner was starting, and the runner's push was rejected seconds later. The web app no longer writes there, but losing a build to a lost race is worth guarding against on its own, so the push rebases and retries. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_0185X6NPgr1v2jXVVDnK5DmZ --- .github/workflows/run-humanstudy-pipeline.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-humanstudy-pipeline.yml b/.github/workflows/run-humanstudy-pipeline.yml index b54b15e..125a1cf 100644 --- a/.github/workflows/run-humanstudy-pipeline.yml +++ b/.github/workflows/run-humanstudy-pipeline.yml @@ -101,11 +101,19 @@ jobs: JOB_ID: ${{ inputs.job_id }} TOKEN: ${{ secrets.HUMANSTUDY_PIPELINE_TOKEN }} run: | + remote="https://x-access-token:$TOKEN@github.com/${{ inputs.jobs_repo }}.git" git config user.name "HumanStudy-Hub Agent" git config user.email "pipeline@humanstudy-hub.org" git add "jobs/$JOB_ID/job.json" git commit -m "agent: start $JOB_ID" - git push "https://x-access-token:$TOKEN@github.com/${{ inputs.jobs_repo }}.git" "HEAD:jobs/$JOB_ID" + # Losing this push loses the whole build, so a branch that moved under + # us is rebased onto rather than treated as a failure. + for attempt in 1 2 3; do + if git push "$remote" "HEAD:jobs/$JOB_ID"; then exit 0; fi + git pull --rebase "$remote" "jobs/$JOB_ID" + done + echo "Could not publish the running state after three attempts." >&2 + exit 1 - name: Run Claude Code through OpenRouter env: