From 30a20f46c6eb24ba822d72a59e3d2dc47706d1d6 Mon Sep 17 00:00:00 2001 From: Muse Sweep Date: Sun, 25 Oct 2026 21:46:47 +0000 Subject: [PATCH] =?UTF-8?q?ci:=20flake-inputs-update=20=E2=80=94=20hand=20?= =?UTF-8?q?off=20validated=20PRs=20the=20token=20cannot=20merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first dispatched run (40234037960) updated both inputs, validated the flake, and opened PR #912, then failed: this repo protects main against the workflow token (gh pr merge: not authorized) and has auto-merge disabled repo-wide (gh pr merge --auto: not allowed). The publish step now treats that specific refusal as a handoff, not a failure: it comments on the PR that the pins are validated and the PR is ready for a privileged merge, warns in the run log, and finishes green. The failure-issue close-out handles the handoff state too (the Fixes line closes the issue when the PR lands). Any other publish error still fails the run. Also filter nix's 'copying path' lines out of the failure-issue error excerpt so it shows the actual error instead of fetch noise. --- .github/workflows/flake-inputs-update.yml | 36 ++++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/.github/workflows/flake-inputs-update.yml b/.github/workflows/flake-inputs-update.yml index df5d527f85..4be117e13b 100644 --- a/.github/workflows/flake-inputs-update.yml +++ b/.github/workflows/flake-inputs-update.yml @@ -8,7 +8,10 @@ # repo's own nix-ci evaluates). This repo has no OpenChamber-specific test # suite, so evaluation is the check — no full test run. If validation passes # and flake.lock moved, the change lands as a pull request that this -# workflow merges itself. +# workflow merges itself. Exception: this repository protects main against +# the workflow token and has auto-merge disabled, so here the PR is +# commented as validated and left for a privileged merge — the same way +# other PRs land in this repo. # # Failures are tracked in ONE issue (title in FAILURE_ISSUE_TITLE below): # the first failure opens it, later failures edit it in place (attempt count, @@ -160,9 +163,10 @@ jobs: fi awk '/^## Failure history/{found=1; next} found' "$RUNNER_TEMP/old-body.md" > "${history_file}" fi - # Error excerpt: last lines of the failing step's log, capped, with - # code fences neutralized so the issue body stays valid Markdown. - tail -n 80 "${ERROR_LOG}" | sed 's/~~~/---/g' | head -c 5000 > "$RUNNER_TEMP/excerpt.txt" || true + # Error excerpt: last lines of the failing step's log with nix's + # "copying path" noise removed, capped, and code fences neutralized + # so the issue body stays valid Markdown. + grep -v "copying path" "${ERROR_LOG}" | tail -n 80 | sed 's/~~~/---/g' | head -c 5000 > "$RUNNER_TEMP/excerpt.txt" || true entry_file="$RUNNER_TEMP/entry.md" { echo "### Attempt ${attempts} — ${now} — openchamber \`${NEW_OC_REV}\`, opencode \`${NEW_OPENCODE_REV}\`" @@ -235,12 +239,27 @@ jobs: pr_number="${pr_url##*/}" echo "Opened PR #${pr_number}: ${pr_url}" merged="false" - if gh pr merge "${pr_number}" --merge; then + handoff="false" + if merge_out=$(gh pr merge "${pr_number}" --merge 2>&1); then merged="true" echo "PR #${pr_number} merged directly." - else - gh pr merge "${pr_number}" --auto --merge + elif auto_out=$(gh pr merge "${pr_number}" --auto --merge 2>&1); then echo "Direct merge was refused; auto-merge enabled for PR #${pr_number}." + else + # This repository protects main against the workflow token and + # has auto-merge disabled, so a validated update PR waits for a + # privileged merge here — the same way other PRs land in this + # repo. Hand it over visibly instead of failing the run: the + # update itself succeeded. Any other publish error still fails. + echo "${merge_out}" + echo "${auto_out}" + if echo "${merge_out}${auto_out}" | grep -qiE "not authorized|not allowed|protected|permission"; then + handoff="true" + gh pr comment "${pr_number}" --body "Validated by the \`flake-inputs-update\` workflow (run: ${RUN_URL}): the flake evaluates with these pins, including the openchamber and opencode package outputs. The workflow's token cannot merge into protected \`main\` and auto-merge is disabled for this repository, so this PR is ready for a privileged merge." + echo "::warning::PR #${pr_number} is validated and ready, but the workflow token cannot merge it (protected main, auto-merge disabled). Left open for a privileged merge." + else + exit 1 + fi fi if [ -n "${EXISTING_NUMBER}" ]; then if [ "${merged}" = "true" ]; then @@ -251,6 +270,9 @@ jobs: gh issue close "${EXISTING_NUMBER}" --reason completed fi echo "Failure issue #${EXISTING_NUMBER} closed." + elif [ "${handoff}" = "true" ]; then + gh issue comment "${EXISTING_NUMBER}" --body "Fixed by PR #${pr_number}: openchamber \`${NEW_OC_REV}\` and opencode \`${NEW_OPENCODE_REV}\` validate against this flake (run: ${RUN_URL}). The workflow token cannot merge into protected \`main\`, so the PR is waiting for a privileged merge; its \`Fixes #${EXISTING_NUMBER}\` line closes this issue when it lands." + echo "Failure issue #${EXISTING_NUMBER} will close when PR #${pr_number} merges." else gh issue comment "${EXISTING_NUMBER}" --body "Fixed by PR #${pr_number}: openchamber \`${NEW_OC_REV}\` and opencode \`${NEW_OPENCODE_REV}\` validate against this flake (run: ${RUN_URL}). The PR carries a \`Fixes #${EXISTING_NUMBER}\` line and is set to auto-merge; this issue closes when it lands." echo "Failure issue #${EXISTING_NUMBER} will close when PR #${pr_number} merges."