diff --git a/.github/workflows/rebase-prs-with-develop.yml b/.github/workflows/rebase-prs-with-develop.yml new file mode 100644 index 0000000000..326ceb573e --- /dev/null +++ b/.github/workflows/rebase-prs-with-develop.yml @@ -0,0 +1,40 @@ +name: Rebase PRs with develop + +on: + push: + branches: + - develop + +jobs: + sync-prs: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Rebase all open non-Dependabots PRs with develop branch as base + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Get all open PRs targeting develop, excluding Dependabot + prs=$(gh pr list --state open --base develop --limit 100 --json number,author --jq '.[] | select(.author.is_bot != true) | .number') + + for pr in $prs; do + echo "Processing PR #$pr" + gh pr checkout $pr + git fetch origin develop + + # Attempt rebase + if git rebase origin/develop; then + echo "PR #$pr rebased successfully. Pushing changes..." + git push --force-with-lease + else + echo "Conflict in PR #$pr. Rebase aborted." + git rebase --abort + # Optional: Notify author + gh pr comment $pr --body "⚠️ Automatic rebase failed due to conflicts. Please rebase manually." + fi + done