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.
While Mergify supports GitLab as a CI reporting job status to GitHub, Mergify does not support GitLab as a development platform (merge requests, etc).
Before 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.
Once 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 successfulconditions:- 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.
The 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;