Label
Add, remove, or toggle labels on a pull request.
The label action allows Mergify to automatically add or remove labels from a
pull request based on the conditions specified in your rules.
A label named in add or toggle that does not exist in the repository yet is
created with a randomly picked color. Create it yourself first if you want to
choose its color and description. Mergify only adds labels the pull request does
not already carry, and only removes ones it does, so a rule whose conditions
keep matching does not keep calling GitHub.
Parameters
Section titled Parametersadd#The list of labels to add.
remove#The list of labels to remove.
remove_all#Remove all labels from the pull request.
toggle#Toggle labels in the list based on the conditions. If all the conditions are a success, all the labels in the list will be added, otherwise, they will all be removed.
Examples
Section titled Examplespull_request_rules: - name: add "WIP" label when the title contains "WIP" conditions: - title ~= WIP actions: label: toggle: - WIPIn this example, Mergify will automatically add the “WIP” label to any pull request whose title contains “WIP”. If the pull request does not match the rule anymore, the label will be removed.
Warn on Conflicts
Section titled Warn on ConflictsWhen browsing the list of pull requests, GitHub does not give any indication on which pull requests might be in conflict. Mergify lets you do this by adding a label.
pull_request_rules: - name: warn on conflicts conditions: - conflict actions: comment: message: "@{{author}} this pull request is now in conflict 😩" label: toggle: - conflictThen, your pull request list will look like this on conflict:
Toggle A Label Based on CI Status
Section titled Toggle A Label Based on CI StatusThis rule toggles a label based on the failure status of a CI system.
pull_request_rules: - name: toggle labels based on CI state conditions: - check-failure = CI actions: label: toggle: - "CI:fail"Add A Label Based on The Target Branch
Section titled Add A Label Based on The Target BranchThis rule adds a static label to pull requests targeting a given branch.
pull_request_rules: - name: label pull requests targeting the release branch conditions: - base = release actions: label: add: - "release"Was this page helpful?
Thanks for your feedback!