Giter VIP home page Giter VIP logo

merge-queue's Introduction

MergeQueue Github Action

Merge your Pull Requests in a safe way.

Have you ever merged a branch that made all tests fail? Even if they were all green before merging? This is called "Semantic Conflicts".

This happens because we merge outdated branches. To solve it, one can block Pull Requests merges from branches that are not up-to-date. However, this quickly evolves into a race between all developers where people will update their branches and be the first to merge, making others force their updates again. This wastes precious CI time and grows resentment within the members of the team.

This is why MergeQueue exists. MergeQueue is a Github action that will merge stuff for you in a smart way. Whenever you want to merge a Pull Request, just add your ready-to-merge label to it. MergeQueue will put your Pull Request in the queue and merge it soon as possible. MergeQueue is capable of:

  • Merge your Pull Requests.
  • Update outdated branches only when necessary.
  • Report errors if your branch has conflicts.
  • Wait for a short time if you add the ready-to-merge to a PR by mistake.

Using this action

First things first, this action requires a Github token that will fire other actions. According to Github docs, this can't be achieved using the default Github token. Instead you will need to use a personal access token. So make sure you have one before configuring MergeQueue.

MergeQueue has to be configured in two different workflows to ensure it works as expected.

When merging branches into your base branch

Add the following workflow to your project:

name: 'Main branch CI'
on:
  push:
    # This should be your base branch
    branches:
      - main

jobs:
  merge-queue:
    runs-on: ubuntu-latest
    steps:
      - name: MergeQueue
        uses: serchinastico@mergequeue
        with:
          # Your Github token goes here
          github-token: ${{ secrets.MERGE_QUEUE_GH_TOKEN }}

This workflow makes sure to fire the next Pull Request in the queue after a successful merge into your base branch.

When a Pull Request changes its state

Add the following workflow to your project:

name: 'Pull Request CI'
on:
  pull_request:
    # Default types are opened, synchronize and reopened
    # Make sure to add labeled as well to fire MergeQueue when adding a label
    types: [opened, labeled, synchronize, reopened]

jobs:
  # Your regular CI steps...
  sleep:
    runs-on: ubuntu-latest
    steps:
      - name: Sleep for 30 seconds
        uses: jakejarvis/wait-action@master
        with:
          time: '30s'
  # Last one is MergeQueue that will try to merge this PR
  merge-queue:
    runs-on: ubuntu-latest
    needs: [sleep]
    steps:
      - name: MergeQueue
        uses: serchinastico@mergequeue
        with:
          github-token: ${{ secrets.MERGE_QUEUE_GH_TOKEN }}

Options

This is the list of options that MergeQueue supports:

option required deafult description
github-token Github token used to apply changes to the Pull Request
base-branch main Name of the default branch where the bot should merge Pull Requests
merge-method squash Method used to merge a Pull Request, possible values are: merge, rebase or squash
grace-time 0 Time (in ms) this script waits before even start. This gives some time for contributors to remove a wrong label
merge-label ready-to-merge Name of the label used to tag PRs as ready-to-merge
block-label do-not-merge Name of the label used to block merges. If this option is present, MergeQueue will never merge this Pull Request
error-label unable-to-merge Name of the label used to notify that MergeQueue can't merge a Pull Request

merge-queue's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar serchinastico avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.