Auto-Merge
Automatically merge or queue pull requests when all merge protection conditions pass.
Mergify can act on a pull request as soon as all applicable merge
protection success_conditions are
satisfied. The exact action (merge directly or add to the merge
queue) depends on whether the merge queue is enabled for the
repository.
Auto-merge is configured with the auto_merge_conditions field under
merge_protections_settings. It accepts true for unconditional auto-merge,
or a list of conditions to restrict the audience.
Configuration
Section titled ConfigurationUnconditional auto-merge
Section titled Unconditional auto-mergeSet auto_merge_conditions: true to auto-merge every pull request that
satisfies the merge protections:
merge_protections_settings: auto_merge_conditions: true
merge_protections: - name: require-review-and-ci if: - base = main success_conditions: - "#approved-reviews-by >= 1" - check-success = ciAny pull request targeting main with at least one approved review and a
passing ci check is automatically merged (or queued if the merge queue is
enabled).
Conditional auto-merge
Section titled Conditional auto-mergePass a list of conditions to restrict auto-merge to pull requests that match.
Only matching pull requests are auto-merged. Other pull requests still need to
be merged manually or queued via the @mergifyio queue command.
merge_protections_settings: auto_merge_conditions: - author = dependabot[bot]The list accepts the same condition syntax as success_conditions, including
nested and, or, and not operators.
Behavior matrix
Section titled Behavior matrixauto_merge_conditions | Merge queue enabled? | Behavior |
|---|---|---|
true | Yes | Every PR is auto-queued. The merge queue then handles routing and merging |
true | No | PR is auto-merged once the merge protections pass |
| List of conditions | Yes | PR is auto-queued when conditions match. The merge queue then handles routing and merging |
| List of conditions | No | PR is auto-merged once both the conditions and the merge protections pass |
| omitted | — | No automatic action. Merge manually or use the @mergifyio queue command |
Accepted and rejected values
Section titled Accepted and rejected valuesauto_merge_conditions accepts:
-
true: unconditional auto-merge. -
A list of conditions: conditional auto-merge.
-
An empty list (
[]): unconditional auto-merge, the same astrue. Auto-merge turns on because the field is set, whatever value it holds, and an empty list restricts nothing.
The schema rejects false and any mapping, empty ({}) or not. An explicit
null is accepted and means the same as omitting the field: auto-merge stays
off.
Examples
Section titled ExamplesBot-only auto-merge
Section titled Bot-only auto-mergeAuto-merge dependency updates from Dependabot, leaving every other pull request to be merged manually:
merge_protections_settings: auto_merge_conditions: - author = dependabot[bot]Label-gated auto-merge
Section titled Label-gated auto-mergeAuto-merge any pull request that carries the ready-to-merge label:
merge_protections_settings: auto_merge_conditions: - label = ready-to-mergeMigrating from autoqueue
Section titled Migrating from autoqueuequeue_rules[].autoqueue is deprecated. The replacement is
auto_merge_conditions in merge_protections_settings.
Mergify opens an automatic migration pull request that rewrites the configuration. The translation depends on the shape of the original configuration:
-
All queues had
autoqueue: true: the migration producesauto_merge_conditions: true. Each queue’s existingqueue_conditionsstill gate routing, so they don’t need to be duplicated. -
One autoqueued queue alongside manual queues: the migration inlines that queue’s
queue_conditionsintoauto_merge_conditions. -
Multiple autoqueued queues alongside manual queues: the migration produces an
orover each autoqueued queue’s conditions. -
Autoqueued queue with empty
queue_conditions: collapses toauto_merge_conditions: true, since an empty list matches every pull request.
The migration pull request touches only those two keys: it removes autoqueue
and writes auto_merge_conditions, leaving the rest of the file, comments
included, as you wrote it. If removing autoqueue empties the block that held
it, that empty block goes too, so the diff carries no leftover queue_rule:.
Queues that were already manual stay manual, and stay reachable via the
@mergifyio queue command.
Two shapes are not migrated automatically: Mergify leaves autoqueue in place
and says why in the deprecation notice. The first is a repository with Merge
Protections disabled, because auto_merge_conditions only takes effect when
that product is enabled. Turn it on first; moving
the key by hand before that stops pull requests from being queued
automatically. The second is a configuration that pulls queue rules in through
extends: those rules
are not in this file, so Mergify cannot rewrite them from here. Set
auto_merge_conditions yourself, then remove autoqueue.
Apply the migration in one step: a configuration that sets
auto_merge_conditions while a queue rule still has autoqueue is rejected.
Example
Section titled ExampleBefore:
queue_rules: - name: dependencies autoqueue: true queue_conditions: - author = dependabot[bot] merge_conditions: - check-success = ci
- name: default queue_conditions: - check-success = ciAfter:
queue_rules: - name: dependencies queue_conditions: - author = dependabot[bot] merge_conditions: - check-success = ci
- name: default queue_conditions: - check-success = ci
merge_protections_settings: auto_merge_conditions: - author = dependabot[bot]Constraints
Section titled ConstraintsMerge Protections must be enabled on the repository for
auto_merge_conditions to take effect, with or without the merge queue. See
Enabling & Configuring Merge Protections.
auto_merge_conditions and queue_rules[].autoqueue cannot be used together.
A configuration that sets both is rejected, so remove autoqueue from your
queue rules in the same change.
Without the merge queue, auto_merge_conditions only takes effect when at
least one merge protection rule applies to
the pull request: with no rule whose if conditions match, there are no
success_conditions to evaluate and nothing is merged. With the merge queue
enabled, a matching pull request is queued whether or not merge protection
rules exist, and the queue’s own conditions gate the merge.
Was this page helpful?
Thanks for your feedback!