Skip to content
git-merge

GitHub Action

No Merge Commits Action

v2.1.0 Latest version

No Merge Commits Action

git-merge

No Merge Commits Action

Prevent merge commits in pull requests

Installation

Copy and paste the following snippet into your .yml file.

              

- name: No Merge Commits Action

uses: NexusPHP/no-merge-commits@v2.1.0

Learn more about this action in NexusPHP/no-merge-commits

Choose a version

git-merge No Merge Commits Action

A Github Action to detect merge commits in pull requests and to prevent them from being merged.

How this works

This action will query GitHub REST API to find all commits in a pull request. After that, this will analyse the response data and check if there are merge commits. If there are any, this action will error and exit.

Usage

name: Detect Merge Commits

on:
  pull_request:

permissions:
  contents: read
  pull-requests: read

jobs:
  test:
    name: Check for merge commits
    runs-on: ubuntu-22.04

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Run test
        uses: NexusPHP/no-merge-commits@v2.1.0
        with:
          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.