Integrating GitLab CI with Mergify
How to automate your GitLab CI workflow using Mergify
GitLab CI/CD offers a seamless integration and delivery system, allowing developers to automate several tasks of the development process. Mergify can interact with GitLab CI when the latter reports as a CI to the GitHub Checks API. This connection paves the way for strong automation processes that depend on the results of your GitLab CI jobs.
Prerequisites
Section titled PrerequisitesBefore you can exploit the capabilities of Mergify with GitLab CI, you should ensure:
-
GitLab CI is correctly set up, and it’s running your project’s pipelines. Refer to the GitLab CI/CD Documentation for assistance with its setup.
-
GitLab CI is configured to report pipeline statuses to GitHub.
-
You have the Mergify GitHub App integrated into your repository.
Utilizing GitLab CI Status Checks with Mergify
Section titled Utilizing GitLab CI Status Checks with MergifyOnce GitLab CI forwards status checks to GitHub, they can be employed as conditions within your Mergify rules.
An illustrative example would be:
pull_request_rules:
- name: Auto-merge when GitLab CI build is successful
conditions:
- check-success = gitlab/ci-pipeline # Adjust this to match your GitLab CI check name
- "#approved-reviews-by >= 1"
actions:
merge:
method: merge
In the given scenario, Mergify will merge pull requests automatically if they possess at least one approved review and the GitLab CI build is successful.
Additional Configuration
Section titled Additional ConfigurationThe potential of merging GitLab CI with Mergify is vast. As an example, Mergify could be tailored to:
-
Automatically update a PR when a build fails;
-
Apply labels, request reviewers, or post comments based on the results of status checks.
We encourage you to explore Mergify’s conditions and actions to create your personalized workflow.