From 2782512b9748b11da7f175b762c17bb7b6fc83ff Mon Sep 17 00:00:00 2001 From: Adam Moussa Date: Fri, 21 Aug 2026 18:57:27 -0400 Subject: [PATCH] ci: enable squash auto-merge on ready PRs --- .github/workflows/auto-merge.yaml | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/auto-merge.yaml diff --git a/.github/workflows/auto-merge.yaml b/.github/workflows/auto-merge.yaml new file mode 100644 index 0000000..a42db32 --- /dev/null +++ b/.github/workflows/auto-merge.yaml @@ -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