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.

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
run: |
set -e

OPEN_PRS=$(gh pr list --repo "$REPOSITORY" --base "$TARGET_BRANCH" --state open --json number --jq '[.[].number | tostring] | join(" ")')
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: |
run: |
set -e

OPEN_PRS=$(gh pr list --repo "$REPOSITORY" --base "$TARGET_BRANCH" --state open --json number --jq '[.[].number | tostring] | join(" ")')

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.

apparently gh pr list is default limited to 30 total PRs from --base this seems reasonable for now but maybe something we need to comment we do a
"5 of 30 limit PRs targeting BASEBranch"

exit 0
fi

if ! PARKED_PRS=$(gh pr list --repo "$REPOSITORY" --base "$TEMP_BRANCH" --state open --json number --jq '[.[].number | tostring] | join(" ")'); then

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.

Same as above

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 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.

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.

3 participants