Using Queue Rules
Learn how to implement queue rules and route your pull requests.
In larger projects with a high volume of pull requests, managing merges can become complex. This is where Mergify’s multiple queue rules feature becomes a game-changer: it enables you to have finer control over the merge process by categorizing pull requests based on any criteria you define.
Queue rules let you organize your PR merge process into separate templates, each with its own merge configuration.
With queue rules, you can:
-
Define multiple queues for different categories of PRs (e.g. dependencies vs. features).
-
Control merge methods (merge, squash, rebase, fast-forward) per queue.
-
Adjust batching behavior (batch size, max wait time).
-
Apply custom conditions for queuing and merging (labels, branch targets, CI checks, file paths, etc.).
Configuring Queue Rules
Section titled Configuring Queue RulesMultiple queue rules are defined under the queue_rules key in your
configuration file. Each rule needs a unique name and can have different
configurations.
queue_rules: - name: urgent # Can be queued early if the PR has the urgent label queue_conditions: - label = urgent # Still requires CI to pass before merge merge_conditions: - check-success = myci
- name: default # Requires CI both for queueing and merging queue_conditions: - check-success = myciConfiguration Options
Section titled Configuration OptionsThe top-level key queue_rules allows you to define the rules that reign over
your merge queue.
Here are all the available fields you can configure for a queue rule:
allow_inplace_checks#Deprecated: this value is computed automatically. In-place checks are enabled only when:
max_parallel_checks == 1- every queue has
batch_size == 1 - every queue CI is single-step (no extra
merge_conditions; either empty or identical toqueue_conditions)
allow_queue_branch_edit#When creating a branch for a queue, if the commits of this branch are edited by an entity external to Mergify, Mergify dequeues all pull requests embarked in the branch and report the issue as a failure. If set to true, Mergify will allow such modifications and trust the content of the branch. Make sure only Mergify and your external application are allowed to edit these branches.
autoqueue#When set to true, automatically add a pull request to the queue when it matches the queue conditions. When false, the pull request must be manually queued. Deprecated: use merge_protection_settings.auto_merge_conditions instead.
batch_max_failure_resolution_attempts#The number of attempts to resolve a batch failure before dequeueing pull requests. By default, Mergify will attempt to resolve a batch failure by splitting the batch multiple times until it finds the root cause of the failure. You can stop this process earlier by limiting the number of resolution attempts. Setting this to 0 will dequeue all the pull requests from a batch when a batch fails.
batch_max_wait_time#The maximum amount of time to wait for additional pull requests before processing a batch that hasn't reached batch_size. The timer starts when the first pull request enters the batch. If batch_size is reached before this time expires, the batch processes immediately. This does not enforce a minimum delay between batches.
batch_size#The maximum number of pull requests per speculative check in the queue. Must be between 1 and 128.
branch_protection_injection_mode#Branch protections conditions injection mode to use.
queuewill inject branch protections conditions as required conditions for queuing and merging pull requests.mergewill inject branch protections conditions as required conditions only for merging pull requests.nonewill disable branch protections. This mode is supported only on queues using amerge_bot_accountwith admin rights.
checks_timeout#The amount of time the merge queue waits for pending checks to return before dequeueing pull requests. This cannot be less than 60 seconds.
commit_message_format#Declarative commit message format configuration. Use this instead of the Jinja2 commit_message_template for the common merge-commit shapes. Mutually exclusive with commit_message_template on the same rule.
commit_message_template#Template to use as the commit message when using the merge or squash merge method.
draft_bot_account#Mergify can impersonate a GitHub user to create its draft pull requests. If no draft_bot_account is set, Mergify creates the draft pull request itself. The user account must have already been logged in Mergify dashboard once and have admin, write or maintain permission.
max_checks_retries#Number of times Mergify will retry failed CI checks before removing the pull request from the queue. On each retry, the draft pull request is recreated to trigger a fresh CI run. This is useful for handling flaky CI. When set to a value greater than 0, in-place checks are disabled and a draft pull request is always created. Set to 0 (default) to disable retries.
merge_bot_account#Mergify can impersonate a GitHub user to merge pull requests. If no merge_bot_account is set, Mergify merges the pull request itself. The user account must have already been logged in Mergify dashboard once and have write or maintain permission.
merge_conditions#The list of conditions to match to get the queued pull request merged. In case of draft pull request, the merge conditions for checks are evaluated against the temporary pull request instead of the original one.
merge_method#Merge method to use. If no value is set, Mergify uses the first authorized method available in the repository configuration.
Additionally, merge-batch merges the draft pull request prepared by the merge queue using a merge commit. This requires batch_size > 1.
name#Name of the queue rule.
queue_branch_merge_method#If set to fast-forward, Mergify will merge the draft pull request instead of merging the original pull request that has been checked. This only works when merge_method is set to merge.
queue_branch_prefix#Prefix for the merge queue branch name
queue_conditions#The list of conditions that needs to match to queue the pull request.
update_bot_account#For certain actions, such as rebasing branches, Mergify has to impersonate a GitHub user. You can specify the account to use with this option. If no update_bot_account is set, Mergify uses the pull request author instead. The user account must have already been logged in Mergify dashboard once. This option overrides the value defined in the queue rules section of the configuration.
update_method#Method to use to update the pull request with its base branch when the check is done in place. Possible values:
mergeto merge the base branch into the pull request.rebaseto rebase the pull request against its base branch.
When null, defaults to merge except if merge_method is fast-forward then it defaults to rebase.
Merge Method
Section titled Merge MethodThe merge_method option controls how pull requests are merged into the base
branch. Accepted values are merge, rebase, squash, fast-forward, and
merge-batch.
Each method produces a different git history shape. See the Merge Strategies guide for a detailed comparison, including configuration examples and trade-offs.
Queue vs. Merge Conditions
Section titled Queue vs. Merge Conditions-
queue_conditions→ Requirements for a PR to be accepted into the queue. Example: a label, a CI check, or a branch filter. -
merge_conditions→ Requirements for a PR to be merged once it reaches the front of the queue. Example: all CI checks passed, required approvals.
This separation lets you schedule PRs early (e.g. based on labels) while still enforcing stricter checks before merge. This can be used to implement two-step CI.
You can find more details about the lifecycle of pull request in the documentation.
Auto‑Queueing Pull Requests
Section titled Auto‑Queueing Pull RequestsControl auto-queueing with
auto_merge_conditions in
merge_protections_settings. It accepts true for unconditional auto-merge,
or a list of conditions to restrict the audience.
Was this page helpful?
Thanks for your feedback!