ci: enable squash auto-merge on ready PRs (PLAT-108) (#126)
Some checks failed
ci / ci / ci (push) Has been cancelled

* ci: enable squash auto-merge on ready PRs

* fix: add auto-merge.yaml as a release exclusion

* fix(ci): serialize auto-merge enable and ignore already-enabled
This commit is contained in:
Adam Moussa 2026-08-21 23:34:16 +00:00 • committed by GitHub
parent 8ec1f627fe
commit f2f2d4066c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 45 additions and 0 deletions

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

@ -0,0 +1,44 @@
name: Enable auto-merge
on:
pull_request:
types: [opened, ready_for_review, reopened, synchronize]
branches: [main]
concurrency:
group: enable-auto-merge-${{ github.event.pull_request.number }}
cancel-in-progress: true
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
if ! out=$(gh pr merge "$PR" --repo "$REPO" --auto 2>&1); then
echo "$out"
if [ "$(gh pr view "$PR" --repo "$REPO" --json autoMergeRequest --jq '.autoMergeRequest != null')" = "true" ]; then
echo "auto-merge already enabled"
exit 0
fi
exit 1
fi
printf '%s\n' "$out"

View file

@ -32,6 +32,7 @@ on:
- "!.github/workflows/labeler.yaml"
- "!.github/workflows/policy.yaml"
- "!.github/workflows/release-on-merge.yaml"
- "!.github/workflows/auto-merge.yaml"
workflow_dispatch:
inputs:
version: