diff --git a/.github/workflows/auto-rebase-merge.yml b/.github/workflows/auto-rebase-merge.yml new file mode 100644 index 00000000..32dcc402 --- /dev/null +++ b/.github/workflows/auto-rebase-merge.yml @@ -0,0 +1,26 @@ +name: Auto-rebase merge single-commit PRs + +on: + pull_request: + types: [opened, synchronize] + +permissions: + contents: write + pull-requests: write + +jobs: + auto-merge: + runs-on: ubuntu-latest + steps: + - name: Check and enable auto-merge with rebase + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + commit_count=$(gh pr view "$PR_NUMBER" --json commits -q '.commits | length') + + if test "$commit_count" -eq 1; then + gh pr merge "$PR_NUMBER" --rebase --auto + echo "Enabled auto-merge with rebase for single-commit PR" + fi