Post Check
Create a check-run on a pull request.
The post_check
action allows Mergify to create a check-run on a pull request.
This can be useful in situations where you want to add a custom check to the
status of a pull request based on Mergify's evaluation.
Checks posted by Mergify using this action are usable as any other condition. See the example below.
Parameters
Key name | Value type | Default | |
---|---|---|---|
success_conditions | list of condition | ||
List of conditions to match to mark the pull request check as succeeded, otherwise, it will be marked as failing. If unset, the conditions from the rule that triggers this action are used. | |||
summary | template | ||
The summary of the check. | |||
title | template | ||
The title of the check. |
As the title
and summary
are
templates, you can benefit from any pull
request attributes, e.g. {{author}}
,
and also these additional variables:
-
{{ check_rule_name }}
the name of the rule that triggered this action; -
{{ check_succeed }}
istrue
if all the conditions match,false
otherwise;
{{ check_conditions }}
the list of all conditions with a checkbox marked if the condition matches.
Examples
Check Number of Approvals
pull_request_rules:- name: post a check when PR is approvedconditions:- "#approved-reviews-by>=2"actions:post_check:title: PR Approvedsummary: This PR has been approved by at least 2 developers.
In this example, when a pull request has at least 2 approved reviews, Mergify will add a new check titled "PR Approved" and set the summary and text as indicated. This will be visible in the checks section of the pull request on GitHub.
Enforcing Conventional Commits
You might want to enforce some guidelines as how to write pull request titles. The following rules add such a check, making sure your team follows Conventional Commits.
The check will be posted only on pull requests targeting the main branch. The check's conclusion will be a success if the title contains a conventional commit type, otherwise it will be a failure.
pull_request_rules:- name: Conventional Commitconditions:- base=mainactions:post_check:success_conditions:- "title~=^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\\(.+\\))?:"title: |{% if check_succeed %}Title follows Conventional Commit{% else %}Title does not follow Conventional Commit{% endif %}summary: |{% if not check_succeed %}Your pull request title must follow [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/).{% endif %}
The result of this check will be visible in GitHub user interface, near the merge button.

Checks posted by Mergify using this action are usable for any other conditions. Taking the, you could use the posted check to add a label when a pull request does not match your convention:
pull_request_rules:- name: label non compliant pull requestsconditions:- "check-failure=Rule: Convention Commit (post_check)"label:toggle:- non-compliant