Configuration Data Types
The different data types you can find in Mergify configuration file
When using templates or conditions, data are made of different types. You will find below the different data types that are available and exposed in Mergify configuration file.
Commit
Section titled CommitA commit is an object that embeds several information about a Git commit
Key name | Value type | |
---|---|---|
author | string or null | |
Name of the author | ||
commit_message | string | |
commit_verification_verified | boolean | |
Indicates if the commit has been marked as verified by GitHub | ||
committer | string or null | |
Name of the committer | ||
date_author | string or null | |
date_committer | string or null | |
email_author | string or null | |
email_committer | string or null | |
gh_author_login | string or null | |
GitHub login of the author | ||
parents | list of string | |
sha | string |
You can use a commit object in templates:
{% for commit in commits %}
Co-Authored-By: {{ commit.author }} <{{ commit.email_author }}>
{% endfor %}
You can also use those objects in conditions:
pull_request_rules:
- name: check that commits are not too old
conditions:
- commits[*].date_committer < 365 days ago
actions:
comment:
message: One of the commit is too old!
Commit Author
Section titled Commit AuthorKey name | Value type | |
---|---|---|
email | string or null | |
Email address of the author | ||
name | string or null | |
Name of the author |
Regular Expressions
Section titled Regular ExpressionsYou can use regular expressions with matching operators in your conditions.
Mergify leverages Python regular expressions to match rules.
pull_request_rules:
- name: add python label if a Python file is modified
conditions:
- files ~= \.py$
actions:
label:
add:
- python
- name: automatic merge for main when the title does not contain “WIP” (ignoring case)
conditions:
- base = main
- -title ~= (?i)wip
actions:
merge:
method: merge
Schedule
Section titled ScheduleThis format represents a schedule. It can contains only days, only times or both and can have a timezone specified with the times (for the list of available time zones, see IANA format. If no timezone is specified, it defaults to UTC.
schedule = Mon-Fri
schedule = 09:00-19:00
schedule = 09:00-19:00[America/Vancouver]
schedule != Mon-Fri 09:00-19:00[America/Vancouver]
schedule != SAT-SUN
Timestamp
Section titled TimestampThe timestamp format must follow the ISO 8601 standard. If the timezone is missing, the timestamp is assumed to be in UTC. The supported timezones come from the IANA database.
Supported formats:
2021-04-05
2012-09-17T22:02:51
2008-09-22T14:01:54Z
2013-12-05T07:19:04-08:00
2013-12-05T07:19:04[Europe/Paris]
- name: end of life version 10.0
conditions:
- base = stable/10.0
- updated-at <= 2021-04-05
actions:
comment:
message: |
The pull request needs to be rebased after end of life of version 10.0
Timestamp Interval
Section titled Timestamp IntervalMergify supports ISO8601 time intervals for some of the exposed attributes.
If the timezone is missing, the timestamp is assumed to be in UTC. The supported timezones come from the IANA database.
2023-07-13T14:00/2023-07-13T16:00
2023-07-13T14:00:00.123/2023-07-13T16:00:00.123
2023-07-13T14:00Z/2023-07-13T16:00Z
2023-07-13T14:00/2023-07-13T16:00[Europe/Paris]
- name: merge except on new year day
conditions:
- current-datetime != 2023-01-01T00:00/2023-01-01T23:59[Europe/Paris]
actions:
merge:
Unspecified digits can also be used for some part of the timestamp:
# 14:00 to 19:00 the 14th of July of every year
XXXX-07-14T14:00/XXXX-07-14T19:00[Europe/Paris]
# 14:00 to 19:00 every day of July of every year
XXXX-07-XXT14:00/XXXX-07-XXT19:00[Europe/Paris]
# 14:00 to 19:00 every day of July of 2023
2023-07-XXT14:00/XXXX-07-XXT19:00[Europe/Paris]
# 14:00 to 19:00 every 31st day of every month of 2023
# If a month doesn't have a 31st day it will be skipped
2023-XX-31T14:00/2023-XX-31T19:00[Europe/Paris]
# 14:00 to 19:00 every 31st day of every month of every year
XXXX-XX-31T14:00/XXXX-XX-31T19:00[Europe/Paris]
Relative Timestamp
Section titled Relative TimestampTimestamps can be expressed relative to the current date and time. The format
is [DD days] [HH hours] [MM minutes] ago
:
DD
, the number of daysHH
, the number of hoursMM
, the number of minutes
If the current date is 18th June 2020, updated-at >= 14 days ago
is
translated to updated-at >= 2020-06-04T00:00:00
.
- name: close stale pull request
conditions:
- base = main
- -closed
- updated-at < 14 days 3 hours 2 minutes ago
actions:
close:
message: |
This pull request looks stale. Feel free to reopen it if you think it's a mistake.
Duration
Section titled DurationDuration can be expressed as quantity unit [quantity unit...]
where quantity
is a number (possibly signed); unit is second, minute, hour, day, week, or
abbreviations or plurals of these units;
1 day 15 hours 6 minutes 42 seconds
1 d 15 h 6 m 42 s
Priority
Section titled PriorityPriority values can be expressed by using an integer between 1 and 10000. You can also use those aliases:
low
(1000)medium
(2000)high
(3000)
priority_rules:
- name: my hotfix priority rule
conditions:
- base = main
- label = hotfix
- check-success = linters
priority: high
- name: my low priority rule
conditions:
- base = main
- label = low
- check-success = linters
priority: 550
Template
Section titled TemplateThe template data type is a regular string that is rendered using the Jinja2 template language.
If you don’t need any of the power coming with this templating language, you can just use this as a regular string.
However, those templates allow to use any of the pull request attributes in the final string.
For example the template string:
Thank you @{{author}} for your contribution!
will render to:
Thank you @jd for your contribution!
when used in your configuration file — considering the pull request author
login is jd
.
Jinja2 filters are supported, you can build string from list for example with:
Approved by: @{{ approved_reviews_by | join(', @') }}
Jinja2 string manipulation are also supported, you can split string for example with:
{{ body.split('----------')[0] | trim }}
Mergify also provides custom Jinja2 filters:
markdownify
: to convert HTML to Markdown:
{{ body | markdownify }}
get_section(<section>, <default>)
: to extract one Markdown section
{{ body | get_section("## Description") }}
GitHub Repository Permissions
Section titled GitHub Repository PermissionsEither none
, read
, triage
, write
, maintain
or admin
.
Queue Dequeue Reason
Section titled Queue Dequeue ReasonThis describes the reason why a pull request has been removed from the queue.
Reason | Description |
---|---|
none | Pull request was not and is not in any queue. |
pr-merged | Pull request has been merged. |
pr-dequeued | Pull request has been removed from the queue by an dequeue command or by an automation rule |
checks-timeout | The configured
|
checks-failed | The checks have failed. |
queue-rule-missing | The queue rule has been removed from the configuration. |
base-branch-missing | The pull request base branch is missing. |
base-branch-changed | The pull request base branch has changed. |
pr-unexpectedly-failed-to-merge | An unexpected error happened while merging the pull request. |
batch-max-failure-resolution-attempts | The maximum number of resolution attempts set in
batch_max_failure_resolution_attempts has been reached. |
conflict-with-base-branch | The pull request conflicts with its base branch. |
conflict-with-pull-ahead | The pull request conflicts with a pull request ahead of it. |
branch-update-failed | Updating the head branch of the pull request failed. |
pr-ahead-dequeued | A pull request which is ahead has been removed from the queue. |
pr-ahead-failed-to-merge | The pull request which is ahead could not be merged. |
pr-with-higher-priority-queued | A higher priority pull request has been queued in the meantime. |
pr-queued-twice | The pull request got queued twice. |
pr-frozen-no-cascading | The pull request was frozen by a freeze with cascading effect disabled. |
pr-checks-stopped-because-merge-queue-pause | The checks have been interrupted because the merge queue is paused on this repository. |
draft-pull-request-changed | The draft pull request has been unexpectedly changed. |
pull-request-updated | The pull request has been manually updated. |
merge-queue-reset | The merge queue was reset. |
incompatibility-with-branch-protections | The pull request cannot be checked because of an incompatibility with branch protections. |
Report Modes
Section titled Report ModesReport modes allow you to choose the type of report you want for your actions.
Report mode values can be expressed in the configuration as a list of strings.
The default value is ["check"]
and the list can’t be empty.
To fill the list, the following report modes are available:
Mode | Description |
---|---|
check | Report the action’s result as a GitHub check on the Pull Request. This is the default report mode. |
comment | Report the action’s result as a comment on the Pull Request |
Report mode option is currently supported for only the following actions: backport
, copy
.