Skip to content

github actions: preserve open CLK PRs during lt-rebase-merge#1341

Open
bmastbergen wants to merge 1 commit into
mainfrom
{bmastbergen}_main
Open

github actions: preserve open CLK PRs during lt-rebase-merge#1341
bmastbergen wants to merge 1 commit into
mainfrom
{bmastbergen}_main

Conversation

@bmastbergen

Copy link
Copy Markdown
Collaborator

When lt_rebase_merge.sh runs, it deletes and recreates the ciq-6.X.y branch, which causes GitHub to auto-close any open PRs targeting it.

Add park/restore steps around the script invocation in the workflow: before the script runs, open PRs are retargeted to a temporary parking branch; after it succeeds, they are moved back to the new ciq-6.X.y.

On failure, PRs remain on the parking branch (still open) and a comment explains the situation. The parking branch is uniquely named with the run ID to avoid collisions with stale branches from prior failures.

Both transitions leave a comment on affected PRs so authors know what happened and that they need to rebase.

Copilot AI review requested due to automatic review settings June 12, 2026 20:39
@bmastbergen bmastbergen requested a review from roxanan1996 June 12, 2026 20:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This workflow update aims to prevent GitHub from auto-closing open PRs when lt_rebase_merge.sh deletes and recreates the ciq-X.Y.y base branch by temporarily retargeting affected PRs to a per-run “parking” branch and restoring them afterward.

Changes:

  • Add a “park PRs” step that creates a temporary branch and retargets open PRs before running lt_rebase_merge.sh.
  • Add a “restore PRs” step that retargets parked PRs back to the recreated branch on success (or leaves them parked on failure) and posts explanatory comments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +249 to +251
cd kernel-src-tree
git push origin "origin/${TARGET_BRANCH}:refs/heads/${TEMP_BRANCH}"
echo "TEMP_BRANCH=$TEMP_BRANCH" >> $GITHUB_ENV
Comment thread .github/workflows/lt-rebase-merge.yml Outdated
run: |
set -e

OPEN_PRS=$(gh pr list --repo "$REPOSITORY" --base "$TARGET_BRANCH" --state open --json number --jq '[.[].number | tostring] | join(" ")')
Comment thread .github/workflows/lt-rebase-merge.yml Outdated
exit 0
fi

if ! PARKED_PRS=$(gh pr list --repo "$REPOSITORY" --base "$TEMP_BRANCH" --state open --json number --jq '[.[].number | tostring] | join(" ")'); then
Comment on lines +301 to +305
run: |
if [ -z "$TEMP_BRANCH" ]; then
echo "No temp branch, nothing to restore"
exit 0
fi
Comment on lines +321 to +323
git fetch origin --tags --quiet 2>/dev/null || true
NEW_VERSION=$(git describe --tags --abbrev=0 --match='v*' "origin/${TARGET_BRANCH}" 2>/dev/null || echo "the latest upstream release")

Comment on lines +231 to +236
- name: Park open PRs on temporary branch
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
REPOSITORY: ${{ github.repository }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
Comment thread .github/workflows/lt-rebase-merge.yml Outdated
Comment thread .github/workflows/lt-rebase-merge.yml Outdated
continue
fi
gh pr comment "$pr" --repo "$REPOSITORY" --body-file - <<EOF || true
:white_check_mark: \`${TARGET_BRANCH}\` has been rebased to \`${NEW_VERSION}\`. This PR has been retargeted to the updated branch. You will need to rebase your PR branch onto the new \`${TARGET_BRANCH}\`.

@PlaidCat PlaidCat Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome.

Would love to see an auto attempt at re-basing for the PR, however this is beyond this PR

PlaidCat
PlaidCat previously approved these changes Jun 12, 2026

@PlaidCat PlaidCat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

there are some minor comments but I think this is a great MVP to solve something very annoying.

@shreeya-patel98

shreeya-patel98 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Some of the comments from claude review, feel free to discard the ones which don't make sense :-

  1. The park step lists --base "$TARGET_BRANCH" (ciq-X.Y.y), but the PRs going through this workflow target -next (per the validation up top). Which branch does the script actually recreate, and which one do the open PRs sit on? If they're on -next, the park query finds nothing. Worth nailing down before this runs for real.

  2. Partial park failure: TEMP_BRANCH gets written to $GITHUB_ENV before the retarget loop, so if a gh pr edit dies mid-loop under set -e, some PRs are parked and some aren't — and the un-parked ones can still get auto-closed. Maybe tolerate per-PR failures like the restore loop does.

  3. Stale parking branches never get cleaned up — if a prior run failed and left PRs on _pr_parking_..._run<old>, the next run won't see them (it only queries $TARGET_BRANCH), so they're stuck there forever.

2 and 3 are edge cases, not blockers.

When lt_rebase_merge.sh runs, it deletes and recreates the ciq-6.X.y
branch, which causes GitHub to auto-close any open PRs targeting it.

Add park/restore steps around the script invocation in the workflow:
before the script runs, open PRs are retargeted to a temporary parking
branch; after it succeeds, they are moved back to the new ciq-6.X.y.

On failure, PRs remain on the parking branch (still open) and a comment
explains the situation. The parking branch is uniquely named with the
run ID to avoid collisions with stale branches from prior failures.

Both transitions leave a comment on affected PRs so authors know
what happened and that they need to rebase.
@bmastbergen

bmastbergen commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

Some of the comments from claude review, feel free to discard the ones which don't make sense :-

  1. The park step lists --base "$TARGET_BRANCH" (ciq-X.Y.y), but the PRs going through this workflow target -next (per the validation up top). Which branch does the script actually recreate, and which one do the open PRs sit on? If they're on -next, the park query finds nothing. Worth nailing down before this runs for real.

This workflow is running for PRs against ciq-6.x.y-next (ie. rebase PRs), but the PRs we need to park/restore are PRs targeting ciq-6.x.y. Sort of confusing, but correct.

  1. Partial park failure: TEMP_BRANCH gets written to $GITHUB_ENV before the retarget loop, so if a gh pr edit dies mid-loop under set -e, some PRs are parked and some aren't — and the un-parked ones can still get auto-closed. Maybe tolerate per-PR failures like the restore loop does.

I think this is best effort. If for some reason we only manage to park/restore some PRs, thats still better than today.

  1. Stale parking branches never get cleaned up — if a prior run failed and left PRs on _pr_parking_..._run<old>, the next run won't see them (it only queries $TARGET_BRANCH), so they're stuck there forever.

"Stuck there forever" as far as no workflow is going to do anything about them automatically. But there will still be open PRs that we see out there so we'll know they need to be dealt with. I figured we'd run like this for a while to actually see how things work before we start trying to do automated cleanup of any kind.

2 and 3 are edge cases, not blockers.

@PlaidCat PlaidCat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants