Github Action to Enable Auto Merge
Workflow to automatically merge PR upon checks completion
Github recently added support for automatically merging PR on checks completions. We can write a GitHub action to automate this process.
Github Action Job
enable-automerge:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: automerge
run: gh pr merge --auto --squash "$PR_URL" -t "$PR_TITLE" -b "$PR_BODY"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}