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
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: | |
| 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.
|
Some of the comments from claude review, feel free to discard the ones which don't make sense :-
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.
7587146 to
64d8f51
Compare
This workflow is running for PRs against
I think this is best effort. If for some reason we only manage to park/restore some PRs, thats still better than today.
"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.
|
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.