Skip to content

Commit 8fd0f95

Browse files
committed
feat: auto-update open PR branches after merge to main
When a PR merges, the post-merge workflow now iterates all open PRs and runs gh pr update-branch on each. This eliminates the manual 'Update branch' click when strict status checks require branches to be up to date. Also enabled allow_update_branch on the repo via API. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent 802bb92 commit 8fd0f95

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

.github/workflows/post-merge.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
if: github.event.pull_request.merged == true
2020
permissions:
2121
actions: write
22+
contents: write
2223
steps:
2324
- name: Harden runner
2425
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
@@ -32,3 +33,13 @@ jobs:
3233
gh workflow run ci.yml --ref main --repo "${{ github.repository }}"
3334
gh workflow run security.yml --ref main --repo "${{ github.repository }}"
3435
gh workflow run scorecard.yml --ref main --repo "${{ github.repository }}"
36+
37+
- name: Auto-update open PR branches
38+
env:
39+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
run: |
41+
gh pr list --base main --state open --json number --jq '.[].number' \
42+
--repo "${{ github.repository }}" | while read -r pr; do
43+
echo "Updating PR #$pr"
44+
gh pr update-branch "$pr" --repo "${{ github.repository }}" || true
45+
done

0 commit comments

Comments
 (0)