Skip to content

Block Merge Commits

Actions
Prevent merging pull requests that contain merge commits
v1.0.1
Latest
Star (4)

Block Merge Commits Action

CI

A Github Action to prevent merging pull requests containing merge commits.

How it works

If any commit in the pull request is a merge commit, the check status will be set to error.

⚠️ GitHub's API only returns the first 250 commits of a PR so if you're working on a really large PR your merge commits might not be detected.

Usage

on: pull_request

name: Pull Requests

jobs:
  message-check:
    name: Block Merge Commits

    runs-on: ubuntu-latest

    steps:
      - name: Block Merge Commits
        uses: Morishiri/block-merge-commits-action@v2
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}

You'll also need to add a required status check rule for your action to block merging if it detects merge commits.

Control Permissions

If your repository is using control permissions you'll need to set pull-request: read on either the workflow or the job.

Workflow Config

on: pull_request

name: Pull Request

permissions:
  pull-requests: read

jobs:
  message-check:
    name: Block Merge Commits

    runs-on: ubuntu-latest

    steps:
      - name: Block Merge Commits
        uses: Morishiri/block-merge-commits-action@v2
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}

Job Config

on: pull_request

name: Pull Request

jobs:
  message-check:
    name: Block Merge Commits

    runs-on: ubuntu-latest

    permissions:
      pull-requests: read

    steps:
      - name: Block Merge Commits
        uses: Morishiri/block-merge-commits-action@v2
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}

Block Merge Commits is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Prevent merging pull requests that contain merge commits
v1.0.1
Latest

Block Merge Commits is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.