File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Sync 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
You can’t perform that action at this time.
0 commit comments