From aa560a59e9b563e7881b1e8dc9104d0528331a35 Mon Sep 17 00:00:00 2001 From: William Harrison <87287585+wdhdev@users.noreply.github.com> Date: Wed, 19 Aug 2026 13:27:22 +0800 Subject: [PATCH 1/3] Add GitHub Action to update PR branches on push --- .github/workflows/update-pr-branches.yml | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/update-pr-branches.yml diff --git a/.github/workflows/update-pr-branches.yml b/.github/workflows/update-pr-branches.yml new file mode 100644 index 0000000000..9695d701b0 --- /dev/null +++ b/.github/workflows/update-pr-branches.yml @@ -0,0 +1,41 @@ +name: Update PR Branches + +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +jobs: + update: + name: Update + runs-on: ubuntu-latest + + steps: + - name: Update branches + uses: actions/github-script@v8 + with: + github-token: ${{ secrets.BOT }} + script: | + const { data: prs } = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: "open" + }); + + for (const pr of prs) { + try { + await github.rest.pulls.updateBranch({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number + }); + + console.log(`Updated #${pr.number} (${pr.head.ref})`); + } catch (error) { + console.log(`Could not update #${pr.number}: ${error.message}`); + } + } From d7c47eba87af0a1035ed3385775601d5d2239789 Mon Sep 17 00:00:00 2001 From: William Harrison <87287585+wdhdev@users.noreply.github.com> Date: Wed, 19 Aug 2026 13:30:21 +0800 Subject: [PATCH 2/3] Update update-pr-branches.yml --- .github/workflows/update-pr-branches.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/update-pr-branches.yml b/.github/workflows/update-pr-branches.yml index 9695d701b0..f5696ddc07 100644 --- a/.github/workflows/update-pr-branches.yml +++ b/.github/workflows/update-pr-branches.yml @@ -1,13 +1,7 @@ name: Update PR Branches on: - push: - branches: - - main - -permissions: - contents: write - pull-requests: write + workflow_dispatch: jobs: update: From 977bfa3a9e33b1d5af2d91c990ed8dc1c23df511 Mon Sep 17 00:00:00 2001 From: William Harrison <87287585+wdhdev@users.noreply.github.com> Date: Wed, 19 Aug 2026 13:33:34 +0800 Subject: [PATCH 3/3] Update update-pr-branches.yml --- .github/workflows/update-pr-branches.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update-pr-branches.yml b/.github/workflows/update-pr-branches.yml index f5696ddc07..6c68c989e5 100644 --- a/.github/workflows/update-pr-branches.yml +++ b/.github/workflows/update-pr-branches.yml @@ -1,7 +1,7 @@ name: Update PR Branches on: - workflow_dispatch: + workflow_dispatch: jobs: update: @@ -14,11 +14,17 @@ jobs: with: github-token: ${{ secrets.BOT }} script: | - const { data: prs } = await github.rest.pulls.list({ - owner: context.repo.owner, - repo: context.repo.repo, - state: "open" - }); + const prs = await github.paginate( + github.rest.pulls.list, + { + owner: context.repo.owner, + repo: context.repo.repo, + state: "open", + per_page: 100 + } + ); + + console.log(`Found ${prs.length} open PRs`); for (const pr of prs) { try {