From 7587146391f61ef1aae414830c89e4acde5281c5 Mon Sep 17 00:00:00 2001 From: Brett Mastbergen Date: Fri, 12 Jun 2026 14:22:28 -0400 Subject: [PATCH] github actions: preserve open CLK PRs during lt-rebase-merge 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. --- .github/workflows/lt-rebase-merge.yml | 131 ++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/.github/workflows/lt-rebase-merge.yml b/.github/workflows/lt-rebase-merge.yml index 7e94232b14df6..1f09811040896 100644 --- a/.github/workflows/lt-rebase-merge.yml +++ b/.github/workflows/lt-rebase-merge.yml @@ -228,7 +228,40 @@ jobs: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" + - 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: | + set -e + + OPEN_PRS=$(gh pr list --repo "$REPOSITORY" --base "$TARGET_BRANCH" --state open --json number --jq '[.[].number | tostring] | join(" ")') + + if [ -z "$OPEN_PRS" ]; then + echo "No open PRs targeting ${TARGET_BRANCH}" + exit 0 + fi + + TEMP_BRANCH="_pr_parking_${TARGET_BRANCH}_run${GITHUB_RUN_ID}" + echo "Parking PRs on ${TEMP_BRANCH}: ${OPEN_PRS}" + + cd kernel-src-tree + git push origin "origin/${TARGET_BRANCH}:refs/heads/${TEMP_BRANCH}" + echo "TEMP_BRANCH=$TEMP_BRANCH" >> $GITHUB_ENV + + for pr in $OPEN_PRS; do + echo "Parking PR #$pr on ${TEMP_BRANCH}" + gh pr edit "$pr" --repo "$REPOSITORY" --base "${TEMP_BRANCH}" + gh pr comment "$pr" --repo "$REPOSITORY" --body-file - </dev/null || true + exit 0 + fi + + if [ "$SCRIPT_OUTCOME" = "success" ]; then + cd kernel-src-tree + 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") + + RESTORE_FAILURES=0 + for pr in $PARKED_PRS; do + echo "Retargeting PR #$pr to ${TARGET_BRANCH}" + if ! gh pr edit "$pr" --repo "$REPOSITORY" --base "${TARGET_BRANCH}"; then + echo "❌ Failed to retarget PR #$pr" + gh pr comment "$pr" --repo "$REPOSITORY" --body-file - </dev/null || true + fi + elif [ "$SCRIPT_OUTCOME" = "skipped" ]; then + # Script never ran — TARGET_BRANCH is intact, safe to move PRs back + echo "Rebase was skipped, restoring PRs to ${TARGET_BRANCH}" + RESTORE_FAILURES=0 + for pr in $PARKED_PRS; do + echo "Restoring PR #$pr to ${TARGET_BRANCH}" + if ! gh pr edit "$pr" --repo "$REPOSITORY" --base "${TARGET_BRANCH}"; then + echo "❌ Failed to restore PR #$pr" + gh pr comment "$pr" --repo "$REPOSITORY" --body-file - </dev/null || true + fi + else + # Script ran and failed — TARGET_BRANCH may be in unknown state, don't move PRs + echo "⚠️ Rebase merge failed, leaving PRs on ${TEMP_BRANCH}" + for pr in $PARKED_PRS; do + gh pr comment "$pr" --repo "$REPOSITORY" --body-file - <