Skip to content

Commit 30b2bed

Browse files
committed
chore: automation of rebasing open non dependabot PRs with develop branch
1 parent 1d530a3 commit 30b2bed

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Rebase PRs with develop
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
sync-prs:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Rebase all open non-Dependabots PRs with develop branch as base
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
run: |
22+
# Get all open PRs targeting develop, excluding Dependabot
23+
prs=$(gh pr list --state open --base develop --limit 100 --json number,author --jq '.[] | select(.author.is_bot != true) | .number')
24+
25+
for pr in $prs; do
26+
echo "Processing PR #$pr"
27+
gh pr checkout $pr
28+
git fetch origin develop
29+
30+
# Attempt rebase
31+
if git rebase origin/develop; then
32+
echo "PR #$pr rebased successfully. Pushing changes..."
33+
git push --force-with-lease
34+
else
35+
echo "Conflict in PR #$pr. Rebase aborted."
36+
git rebase --abort
37+
# Optional: Notify author
38+
gh pr comment $pr --body "⚠️ Automatic rebase failed due to conflicts. Please rebase manually."
39+
fi
40+
done

0 commit comments

Comments
 (0)