trails/.github/workflows/automerge.yml
Ullrich Schäfer 3a4119e00e Restrict automerge to PRs targeting main
Prevents stacked PRs from being auto-merged into feature branches.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 00:53:33 +00:00

51 lines
1.3 KiB
YAML

name: Automerge
# Triggers:
# - pull_request: fires when PR is opened, labeled, updated, etc.
# Handles the case where the label is added after CI already passed.
# - workflow_run (CI): fires after the CI workflow completes.
# This is needed because check_suite and status events don't reliably
# fire for workflows on the same commit (GitHub prevents infinite loops).
# Without this, the automerge action never retries after CI passes.
on:
pull_request:
types:
- labeled
- unlabeled
- synchronize
- opened
- edited
- ready_for_review
- reopened
- unlocked
pull_request_review:
types:
- submitted
workflow_run:
workflows: ["CI"]
types:
- completed
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
automerge:
name: Automerge PR
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v6
- name: Automerge
uses: pascalgn/automerge-action@v0.16.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MERGE_LABELS: "automerge"
MERGE_METHOD: "merge"
MERGE_DELETE_BRANCH: "true"
MERGE_READY_STATE: "clean"
UPDATE_METHOD: "rebase"
BASE_BRANCHES: "main"