From b910fcd3b284e32a550b73023af9c73e9d1bc559 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Wed, 18 Nov 2026 20:00:59 -0500 Subject: [PATCH] fix(repin): keep the open re-pin PR open when a newer release re-runs it A re-run reset chore/repin-ci-workflows to the base before committing, which emptied the open PR's diff; GitHub closed it, and the auto-merge step then failed on the closed PR (run 44433009022, #17322). The commit is now built on a scratch branch and the PR branch moved to it in one force update. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vcupoo79EqmECYFZ4MTv6C --- .../maintenance-repin-ci-workflows.yml | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/maintenance-repin-ci-workflows.yml b/.github/workflows/maintenance-repin-ci-workflows.yml index e5ae649f340..62dfc5b5e22 100644 --- a/.github/workflows/maintenance-repin-ci-workflows.yml +++ b/.github/workflows/maintenance-repin-ci-workflows.yml @@ -106,26 +106,33 @@ jobs: while IFS= read -r path; do base64 -w0 "$path" | jq -Rsc --arg path "$path" '{path: $path, contents: .}' >>"$adds" done < <(git ls-files --modified --others --exclude-standard) - if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$branch" --silent 2>/dev/null; then - gh api -X PATCH "$refs/heads/$branch" -f sha="$base_sha" -F force=true --silent - else - gh api -X POST "$refs" -f ref="refs/heads/$branch" -f sha="$base_sha" --silent - fi + # Built on a scratch branch, then moved onto $branch in one force + # update: resetting an open PR's branch to the base empties its diff, + # and GitHub closes the PR. + scratch="$branch-$GITHUB_RUN_ID" + gh api -X POST "$refs" -f ref="refs/heads/$scratch" -f sha="$base_sha" --silent + trap 'gh api -X DELETE "$refs/heads/$scratch" --silent || true' EXIT jq -n \ --arg repo "$GITHUB_REPOSITORY" \ --arg oid "$base_sha" \ - --arg branch "$branch" \ + --arg scratch "$scratch" \ --arg headline "$title" \ --slurpfile additions "$adds" \ '{ query: "mutation($input: CreateCommitOnBranchInput!) { createCommitOnBranch(input: $input) { commit { oid } } }", variables: {input: { - branch: {repositoryNameWithOwner: $repo, branchName: $branch}, + branch: {repositoryNameWithOwner: $repo, branchName: $scratch}, expectedHeadOid: $oid, message: {headline: $headline}, fileChanges: {additions: $additions} }} - }' | gh api graphql --input - | jq -er '.data.createCommitOnBranch.commit.oid' + }' | gh api graphql --input - | jq -er '.data.createCommitOnBranch.commit.oid' >"$RUNNER_TEMP/oid" + oid="$(<"$RUNNER_TEMP/oid")" + if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$branch" --silent 2>/dev/null; then + gh api -X PATCH "$refs/heads/$branch" -f sha="$oid" -F force=true --silent + else + gh api -X POST "$refs" -f ref="refs/heads/$branch" -f sha="$oid" --silent + fi body="$RUNNER_TEMP/body.md" cat >"$body" <