-
Notifications
You must be signed in to change notification settings - Fork 201
31 lines (28 loc) · 917 Bytes
/
rebase-open-prs.yml
File metadata and controls
31 lines (28 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Rebase all open PRs when master is updated
# This keeps PRs up-to-date automatically
name: Rebase Open PRs
on:
push:
branches:
- master
permissions:
contents: write
pull-requests: write
jobs:
rebase-open-prs:
runs-on: ubuntu-latest
steps:
- name: Rebase all open PRs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
gh pr list --state open --json number,author,isDraft --jq '.[] | select(.isDraft == false) | "\(.number) \(.author.login)"' | while read pr author; do
if [ "$author" = "dependabot[bot]" ]; then
echo "Requesting rebase for Dependabot PR #$pr"
gh pr comment "$pr" --body "@dependabot rebase"
else
echo "Updating branch for PR #$pr"
gh pr update-branch --rebase "$pr" || true
fi
done