Integrating GitHub Actions with Mergify

How to leverage GitHub Actions using Mergify.


GitHub Actions Integration with Mergify

Section titled GitHub Actions Integration with Mergify

GitHub Actions is a CI/CD platform provided by GitHub that helps you automate tasks within your software development life cycle. Mergify can interact seamlessly with GitHub Actions by evaluating the status checks that GitHub Actions reports to your repositories. This integration paves the way for powerful automation workflows that respond to the outcomes of your GitHub Actions runs.

Before leveraging Mergify’s features with GitHub Actions, ensure the following:

  1. You’ve set up GitHub Actions in your repository. If you’re new to GitHub Actions, their official documentation provides comprehensive guides.

  2. GitHub Actions is already configured to report job statuses to your pull requests.

  3. The Mergify GitHub App is installed in your repository.

Using GitHub Actions Status Checks in Mergify Configuration

Section titled Using GitHub Actions Status Checks in Mergify Configuration

To harness the full power of Mergify and GitHub Actions, you can utilize status checks reported by GitHub Actions as conditions in your Mergify rules.

Status check example

Based on the example above, to validate the listed jobs, use the following configuration:

pull_request_rules:
- name: Automatically merge when GitHub Actions jobs succeed
conditions:
- check-success=changelog_sync
- check-success=actionlint
- check-success=docker-onpremise
- check-success=docker-saas
- check-success=docker-label
- check-success=add-linear-author-as-reviewer
actions:
merge:
method: merge

Triggering GitHub Actions Workflow via Mergify

Section titled Triggering GitHub Actions Workflow via Mergify

With Mergify, it’s also possible to trigger a GitHub Actions workflow directly. This can be achieved by using the github_actions action in your Mergify configuration.

Further Configuration and Advanced Use Cases

Section titled Further Configuration and Advanced Use Cases

The integration of GitHub Actions with Mergify offers extensive possibilities. You can:

  • Craft rules that depend on specific GitHub Actions job results.

  • Merge pull requests only after certain workflows complete successfully.

  • React to failures in GitHub Actions runs by adding comments, labels, or even requesting reviews.