Skip to content

Commit 1ab8074

Browse files
authored
feat: Auto-rebase open PRs when master is updated (#983)
Add workflow to automatically keep open PRs up-to-date: - Dependabot PRs: uses @dependabot rebase command - Other non-draft PRs: uses gh pr update-branch --rebase - Simplify dependabot-auto-merge.yml by removing redundant update step
1 parent a497950 commit 1ab8074

2 files changed

Lines changed: 31 additions & 6 deletions

File tree

.github/workflows/dependabot-auto-merge.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ jobs:
1313
runs-on: ubuntu-latest
1414
if: github.actor == 'dependabot[bot]'
1515
steps:
16-
- name: Update branch if behind
17-
run: gh pr update-branch --rebase "$PR_URL" || true
18-
env:
19-
PR_URL: ${{ github.event.pull_request.html_url }}
20-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21-
2216
- name: Enable auto-merge
2317
run: gh pr merge --auto --squash "$PR_URL"
2418
env:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Rebase all open PRs when master is updated
2+
# This keeps PRs up-to-date automatically
3+
name: Rebase Open PRs
4+
5+
on:
6+
push:
7+
branches:
8+
- master
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
rebase-open-prs:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Rebase all open PRs
19+
env:
20+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
GH_REPO: ${{ github.repository }}
22+
run: |
23+
gh pr list --state open --json number,author,isDraft --jq '.[] | select(.isDraft == false) | "\(.number) \(.author.login)"' | while read pr author; do
24+
if [ "$author" = "dependabot[bot]" ]; then
25+
echo "Requesting rebase for Dependabot PR #$pr"
26+
gh pr comment "$pr" --body "@dependabot rebase"
27+
else
28+
echo "Updating branch for PR #$pr"
29+
gh pr update-branch --rebase "$pr" || true
30+
fi
31+
done

0 commit comments

Comments
 (0)