name: Auto-merge Release Please PRs
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
branches: [ main ]
permissions:
contents: write
pull-requests: write
jobs:
enable-automerge:
if: >-
startsWith(github.event.pull_request.head.ref, 'release-please--') &&
contains(join(github.event.pull_request.labels.*.name, ','), 'autorelease: pending')
runs-on: ubuntu-latest
steps:
- name: Enable auto-merge (squash)
env:
GH_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
run: |
gh pr merge \
-R "${{ github.repository }}" \
--squash --auto \
"${{ github.event.pull_request.number }}"
- name: Comment that auto-merge is enabled
uses: actions/github-script@v8
with:
github-token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: 'Auto-merge enabled for Release Please PR. It will merge once checks pass.'
})