Using Slack with Mergify

Learn how you can send Slack notifications.


Mergify offers a native integration with Slack, allowing you to receive events from your Merge Queue directly in one or multiple Slack channels. This integration helps you stay updated on your merge activities without leaving Slack. Here’s how you can set it up:

To receive Merge Queue events directly in Slack:

  1. Go to your Mergify dashboard.
  2. Navigate to Integrations → Slack.
  3. Follow the prompts to connect your Slack workspace.
  4. Select the Slack channel where you want to receive Merge Queue notifications.
Merge Queue activity on Slack

With this setup, you’ll get real-time updates about your Merge Queue, keeping your team informed and enabling quicker responses to any issues.

Using GitHub-Slack Integration with Mergify

Section titled Using GitHub-Slack Integration with Mergify

In addition to the native integration, you can also receive Slack notifications based on Mergify actions by leveraging the GitHub to Slack integration. Here’s a step-by-step guide:

Setting Up GitHub-Slack Integration

Section titled Setting Up GitHub-Slack Integration
  1. Go to Slack’s GitHub Integration page.

  2. Click on the ‘Add to Slack’ button.

  3. Invite the GitHub app to the channel you want. Refer to the documentation for more details.

  4. Make sure you subscribe to the repositories to receive the mentions as private message for the GitHub Slack app.

Now that the Slack-GitHub integration is complete, let’s see how you can use Mergify to mention a user, which will then notify them on Slack.

Using Mergify’s Comment Action with Slack Notifications

Section titled Using Mergify’s Comment Action with Slack Notifications

The primary idea is to use Mergify’s (comment)[/workflow/actions/comment/] action to mention the PR author, leveraging GitHub’s mention feature. This mention will be forwarded to Slack, notifying the mentioned user.

Here’s an example of a Mergify configuration that comments on a PR if a CI fails and the label is “hotfix”:

pull_request_rules:
  - name: Notify author on CI failure for hotfixes
    conditions:
      - "#check-failure > 0"
      - "label = hotfix"
    actions:
      comment:
        message: "@{{author}} :warning: The CI failed on this hotfix PR. Please review the issues and address them."

In the above rule:

  • We’re checking if there are any CI failures with #check-failure > 0.

  • We’re also ensuring that the PR has the label hotfix.

  • If both conditions are met, Mergify will leave a comment mentioning the PR author using @{{author}}. This mention will trigger a notification in Slack if the author has their GitHub integrated with Slack.

By setting up this flow, you can ensure that critical PRs, like those labeled “hotfix”, receive immediate attention from their authors, even if they’re primarily monitoring Slack.