ci: enable squash auto-merge on ready PRs

This commit is contained in:
Adam Moussa 2026-08-21 18:51:43 -04:00
parent 3f31b37890
commit 6b1c2a3795
No known key found for this signature in database

32
.github/workflows/auto-merge.yaml vendored Normal file
View file

@ -0,0 +1,32 @@
name: Enable auto-merge
on:
pull_request:
types: [opened, ready_for_review, reopened, synchronize]
branches: [main]
permissions:
contents: write
pull-requests: write
jobs:
enable:
if: >-
github.event.pull_request.draft == false
&& github.event.pull_request.head.repo.full_name == github.repository
&& github.event.pull_request.user.login != 'dependabot[bot]'
&& github.event.pull_request.user.login != 'renovate[bot]'
runs-on: ubuntu-latest
steps:
- name: Enable squash auto-merge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
if [ "$(gh pr view "$PR" --repo "$REPO" --json autoMergeRequest --jq '.autoMergeRequest != null')" = "true" ]; then
echo "auto-merge already enabled"
exit 0
fi
gh pr merge "$PR" --repo "$REPO" --auto