github actions: preserve open CLK PRs during lt-rebase-merge#1341
github actions: preserve open CLK PRs during lt-rebase-merge#1341bmastbergen wants to merge 1 commit into
Conversation
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.
There was a problem hiding this comment.
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.
| 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 |
| run: | | ||
| if [ -z "$TEMP_BRANCH" ]; then | ||
| echo "No temp branch, nothing to restore" | ||
| exit 0 | ||
| fi |
| 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") | ||
|
|
| - 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(" ")') |
There was a problem hiding this comment.
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 |
| 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}\`. |
There was a problem hiding this comment.
Awesome.
Would love to see an auto attempt at re-basing for the PR, however this is beyond this PR
PlaidCat
left a comment
There was a problem hiding this comment.
![]()
there are some minor comments but I think this is a great MVP to solve something very annoying.
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.