Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

The benefits of auto-merging GitHub and GitLab repositories

July 3, 2025
Petr Hracek
Related topics:
Automation and managementCI/CDContainersDeveloper ProductivityDeveloper ToolsLinux
Related products:
Red Hat Developer HubRed Hat Enterprise Linux

Share:

    This article is for developers who want to see what is missing in their GitHub pull requests or GitLab merge requests. We will explain the advantage of automatically merging GitHub pull requests when meeting the conditions and provide information about the status mail about pull requests in specific GitHub repositories.

    Read the previous article for inspiration, Testing Farm as GitHub Action: User stories.

    Prerequisites

    Auto-merger relies on labels marking PRs with missing CI and/or reviews. You can use auto-merge-wrapper GitHub Action to set these labels automatically. Follow the instructions described in the README documentation. As an example, you can refer to our postgresql-container, where the auto-merge-wrapper is on-boarded.

    The GitHub Action will regularly check opened PRs and set labels based on their state. Additionally, it will create comments on PR with status. The validation in Figure 1 shows the status of the pull request.

    The picture in Figure 1 shows the status of validation and tests results
    Figure 1: The validation shows the status of the pull request. 

    The auto-merge-wrapper GitHub Action is a composite action that uses pull-request-validator and auto-merge GitHub Actions in the background. These actions can be additionally configured to ignore specific CI jobs, adjust the number of reviewers, or interact with Bugzilla bugs and Jira issues. For more information, follow the documentation from the README.

    To check GitHub repositories, you must generate an API token, as described in GitHub. Before running the auto-merger github-checker tool, run the following command:

    $ export GH_TOKEN=<your token>

    To check GitLab repositories, generate the API token, as described in this GitLab. Before running the auto-merger gitlab-checker tool, run this command:

    $ export GITLAB_TOKEN=<your token> 

    Installing and configuring auto-merger

    First, you need to install auto-merger by command.

    $ pip3 install git+https://github.com/sclorg/auto-merger.git

    Auto-merger must have a configuration file placed in the $HOME directory with the name ".auto-merger.yaml".

    The configuration file for GitHub looks like this:

    github:
    namespace: "sclorg"
    repos:
       - s2i-ruby-container
       - s2i-perl-container
       - s2i-nodejs-container
    # How many approvals should have PR - default is 2
    approvals: 1
    # How many days, PR should be opened - default is 1 day
    pr_lifetime: 1
    # Labels that blocks merges
    blocker_labels:
       - "pr/failing-ci"
       - "pr/missing-review"
    # Labels that should be present in pull request before merging
    approval_labels:
       - "READY-to-MERGE"

    The configuration file for GitLab looks like this:

    gitlab:
    namespace: “redhat/rhel/containers”
    repos:
    - postgresql-16
    - mysql-84
    - python-312-minimal
    approvals: 1
    # How many days, PR should be opened - default is 1 day
    pr_lifetime: 1
    # Labels that blocks merges
    blocker_labels:
    - "ci-failing"
    - "review-missing"
    # Labels that should be present in pull request before merging
    approval_labels:
    - "READY-to-MERGE"

    Both configurations merge into one file. 

    The fields in the GitHub or GitLab sections are defined as follows:

    • namespace - The namespace in GitHub where repositories mentioned.
    • repos - The repositories we will check.
    • approvals - The number of approvals needed to allow automatic merging.
    • pr_lifetime - Specify the lifetime during which each pull request should be opened.
    • blocker_labels - Specify the blocker labels that block auto-merging each pull request.
    • approval_labels - Specify the approval labels that should be present in each pull request 

    Now that auto-merger has set all the information, let’s see what auto-merger can do.

    How to receive GitHub pull requests status

    Let’s gather all the information about the GitHub repositories mentioned in the configuration file, using the following command:

    $ auto-merge github-checker

    If you would like to receive information about what’s going on, add –send-email to the previous command with your email address.

    The output may look like this:

    $ auto-merge github-checker
    
    Pull requests that are blocked by labels [pr/failing-ci, pr/missing-review]
    
    Let's check repository in sclorg/s2i-ruby-container
    
    Add PR'579' of 's2i-ruby-container' to blocked PRs.
    
    Add PR'575' of 's2i-ruby-container' to blocked PRs.
    
    Add PR'570' of 's2i-ruby-container' to blocked PRs.
    
    Let's check repository in sclorg/s2i-perl-container
    
    Add PR'331' of 's2i-perl-container' to blocked PRs.
    
    Let's check repository in sclorg/s2i-nodejs-container
    
    Add PR'477' of 's2i-nodejs-container' to blocked PRs.
    
    Add PR'476' of 's2i-nodejs-container' to blocked PRs.
    
    
    
    SUMMARY OF BLOCKED PULL REQUESTS
    
    Pull requests that are blocked by labels [pr/failing-ci, pr/missing-review]
    
    s2i-ruby-container
    
    https://github.com/sclorg/s2i-ruby-container/pull/579 pr/missing-review
    
    https://github.com/sclorg/s2i-ruby-container/pull/575 pr/missing-review pr/failing-ci
    
    https://github.com/sclorg/s2i-ruby-container/pull/570 pr/missing-review pr/failing-ci
    
    s2i-perl-container
    
    https://github.com/sclorg/s2i-perl-container/pull/331 pr/missing-review
    
    s2i-nodejs-container
    
    https://github.com/sclorg/s2i-nodejs-container/pull/477 pr/missing-review pr/failing-ci
    
    https://github.com/sclorg/s2i-nodejs-container/pull/476 pr/missing-review

    How to receive GitLab merge requests status

    Let’s gather all the information about the repositories mentioned in the GitLab configuration file, using the following command:

    $ auto-merge gitlab-checker

    If you would like to receive information, you can add –-send-email to the previous command with your email address.

    The output may look like this:

    $ auto-merge gitlab-checker
    
    Let's check repository in redhat/rhel/containers/postgresql-16
    
    - Checking PR 235 for redhat/rhel/containers/postgresql-16
    
    - Checking PR 234 for redhat/rhel/containers/postgresql-16
    
    - Checking PR 180 for redhat/rhel/containers/postgresql-16
    
    - Checking PR 178 for redhat/rhel/containers/postgresql-16
    
    Let's check repository in redhat/rhel/containers/mysql-84
    
    - Checking PR 72 for redhat/rhel/containers/mysql-84
    
    - Checking PR 71 for redhat/rhel/containers/mysql-84
    
    - Checking PR 68 for redhat/rhel/containers/mysql-84
    
    - Checking PR 67 for redhat/rhel/containers/mysql-84
    
    - Checking PR 31 for redhat/rhel/containers/mysql-84
    
    Let's check repository in redhat/rhel/containers/python-312-minimal
    
    - Checking PR 73 for redhat/rhel/containers/python-312-minimal
    
    - Checking PR 72 for redhat/rhel/containers/python-312-minimal
    
    - Checking PR 71 for redhat/rhel/containers/python-312-minimal
    
    - Checking PR 68 for redhat/rhel/containers/python-312-minimal
    
    - Checking PR 49 for redhat/rhel/containers/python-312-minimal
    
    - Checking PR 40 for redhat/rhel/containers/python-312-minimal
    
    - Checking PR 38 for redhat/rhel/containers/python-312-minimal
    
    - Checking PR 37 for redhat/rhel/containers/python-312-minimal
    
    - Checking PR 12 for redhat/rhel/containers/python-312-minimal
    
    
    
    SUMMARY
    
    GitLab merge requests that are blocked by labels [pr/failing-ci, pr/missing-review]
    
    redhat/rhel/containers/postgresql-16
    
    ------
    
    https://gitlab.com/redhat/rhel/containers/postgresql-16/-/merge_requests/235 'chore(deps): update konflux references'
    
    https://gitlab.com/redhat/rhel/containers/postgresql-16/-/merge_requests/234 'checking if tests run'
    
    https://gitlab.com/redhat/rhel/containers/postgresql-16/-/merge_requests/180 'chore(deps): update registry.stage.redhat.io/rhel9/s2i-core:9.6 docker digest to cd24a28'
    
    https://gitlab.com/redhat/rhel/containers/postgresql-16/-/merge_requests/178 'chore(deps): update registry.stage.redhat.io/rhel10/s2i-core:10.0 docker digest to 07d5729'
    
    
    
    redhat/rhel/containers/python-312-minimal
    
    ------
    
    https://gitlab.com/redhat/rhel/containers/python-312-minimal/-/merge_requests/73 'Update registry.access.stage.redhat.com/ubi10/ubi-minimal:10.1 Docker digest to 26a30ce'
    
    https://gitlab.com/redhat/rhel/containers/python-312-minimal/-/merge_requests/72 'Konflux update python-312-minimal-10-0'
    
    https://gitlab.com/redhat/rhel/containers/python-312-minimal/-/merge_requests/71 'checking if tests run'
    
    https://gitlab.com/redhat/rhel/containers/python-312-minimal/-/merge_requests/68 'Use remote build pipeline'
    
    https://gitlab.com/redhat/rhel/containers/python-312-minimal/-/merge_requests/49 'RPM updates'
    
    https://gitlab.com/redhat/rhel/containers/python-312-minimal/-/merge_requests/40 'Update Konflux references'
    
    https://gitlab.com/redhat/rhel/containers/python-312-minimal/-/merge_requests/38 'RPM updates'
    
    https://gitlab.com/redhat/rhel/containers/python-312-minimal/-/merge_requests/37 'Update registry.stage.redhat.io/ubi9/ubi-minimal:9.6 Docker digest to db2f908'
    
    https://gitlab.com/redhat/rhel/containers/python-312-minimal/-/merge_requests/12 'Update sources based on the upstream'
    
    
    
    redhat/rhel/containers/mysql-84
    
    ------
    
    https://gitlab.com/redhat/rhel/containers/mysql-84/-/merge_requests/72 'Lzachar trying 9.7.0'
    
    https://gitlab.com/redhat/rhel/containers/mysql-84/-/merge_requests/71 'Konflux update mysql-84-9-6'
    
    https://gitlab.com/redhat/rhel/containers/mysql-84/-/merge_requests/68 'Update registry.access.stage.redhat.com/ubi10/s2i-core:10.1 Docker digest to 6d3cfdc'
    
    https://gitlab.com/redhat/rhel/containers/mysql-84/-/merge_requests/67 'Try newer task-prefetch-dependencies-oci-ta'
    
    https://gitlab.com/redhat/rhel/containers/mysql-84/-/merge_requests/31 'Update registry.stage.redhat.io/rhel9/s2i-core:9.6 Docker digest to cd24a28'

    When GitHub pull requests meet criteria

    What should you do in case pull requests meet all criteria? Let’s call auto-merger to enable automatic merging.

    In case a pull request meets following criteria:

    • The READY-to-MERGE labels are present.
    • The pull request has enough approvals.

    Then the auto-merger tool merges the pull request.

    Currently, if "pr/failing-ci" and "pr/missing-review" are present in the pull request, then the pull request is merged as well.

    Soon there will be a flag like "merge_even_blocker_labels" that will allow it or disable it.

    To enable auto-merging support, use this easy command: 

    $ auto-merger merger

    To receive information about the merged pull request, add –-send-email to the previous command with your email address.

    If nothing will be merged, you'll see a message like this:

    $ auto-merge merger
    SUMMARY
    There is nothing to merge.

    When there is something to be merged, you will see message like this:

    $ auto-merge merger
    https://github.com/sclorg/s2i-python-container/pull/731 -> CAN BE MERGED
    Let's try to merge 731....
    Pull request 731 was merged 

    Next steps

    You can run the auto-merger tool per user request or execute regularly on some host which is a long-time machine, such as a cronjob. The tool is on-boarded in our organization (e.g., details in the postgresql-container) and sent daily reports about pull requests. From now on, you can execute auto-merger daily, weekly, or even hourly. 

    You can also find out what's going on with your pull request or merge-request. In the end, if you see that something is ready to merge, then execute the auto-merger merger option to automatically merge your pull request or merge request. Do not waste your time browsing web pages. You can run this tool, and it will show you the results. 

    What are the next steps?

    • The option for exporting results to JSON or YAML will follow (i.e., usage for CI systems).

    • Allow disable merging in case of blocker_lables.

    • Improve all GitLab merge requests.

    OSZAR »

    Related Posts

    • Automate CI/CD on pull requests with Argo CD ApplicationSets

    • How to create a pull request: contributing to Open Source

    • Test pull requests with the Try in Web IDE GitHub action

    • Build container images in OpenShift using Podman as a GitLab runner

    Recent Posts

    • Our top 10 articles of 2025 (so far)

    • The benefits of auto-merging GitHub and GitLab repositories

    • Supercharging AI isolation: microVMs with RamaLama & libkrun

    • Simplify multi-VPC connectivity with amazon.aws 9.0.0

    • How HaProxy router settings affect middleware applications

    What’s up next?

    GitOps has become a standard in deploying applications to Kubernetes, and many companies are adopting the methodology for their DevOps and cloud-native strategy. Download the GitOps Cookbook for useful recipes and examples for successful hands-on applications development and deployment with GitOps.

    Get the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue

    OSZAR »