View as Markdown

Workflow Automation

Automate the routine work on your pull requests with rules that react to a pull request's state to label, comment, assign, rebase, merge, and more.


Workflow Automation handles the routine work on your pull requests. You write rules in your Mergify configuration file, and Mergify carries them out: labeling, commenting, assigning, rebasing, merging, and more. Your team spends less time on pull request housekeeping.

Every rule lives under pull_request_rules and pairs a set of conditions with the actions to run when a pull request matches them:

pull_request_rules:
- name: add "WIP" label when the title contains "WIP"
conditions:
- title ~= WIP
actions:
label:
toggle:
- WIP

Here, any pull request whose title contains WIP gets the WIP label. Once the title no longer matches, Mergify removes it.

Mergify evaluates the state of a pull request rather than individual events. It checks the current status of a pull request and acts based on the conditions you defined. This behavior is known as “edge triggering”: once an action has run, Mergify does not run it again while the rule keeps matching. It runs a second time only after the pull request stops matching the rule and then matches again.

Not every action works that way. assign, dismiss_reviews, edit, label, post_check, rebase, request_reviews, review, squash, and update run on every evaluation instead, which is how they hold a pull request in the state a rule describes. The rule above relies on that: if someone removes the WIP label while the title still matches, Mergify puts it back.

Was this page helpful?