Skip to content
alert-circle

GitHub Action

Block Autosquash Commits

v2.2.0 Latest version

Block Autosquash Commits

alert-circle

Block Autosquash Commits

Prevent merging pull requests that contain commit messages prefixed with fixup! or squash

Installation

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

              

- name: Block Autosquash Commits

uses: xt0rted/[email protected]

Learn more about this action in xt0rted/block-autosquash-commits-action

Choose a version

Block Autosquash Commits Action

CI CodeQL

A Github Action to prevent merging pull requests containing autosquash commit messages.

How it works

If any commit message in the pull request starts with fixup! or squash! 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 fixup commits might not be detected.

Usage

on: pull_request

name: Pull Requests

jobs:
  message-check:
    name: Block Autosquash Commits

    runs-on: ubuntu-latest

    steps:
      - name: Block Autosquash Commits
        uses: xt0rted/block-autosquash-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 any fixup! or squash! 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 Autosquash Commits

    runs-on: ubuntu-latest

    steps:
      - name: Block Autosquash Commits
        uses: xt0rted/block-autosquash-commits-action@v2
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}

Job Config

on: pull_request

name: Pull Request

jobs:
  message-check:
    name: Block Autosquash Commits

    runs-on: ubuntu-latest

    permissions:
      pull-requests: read

    steps:
      - name: Block Autosquash Commits
        uses: xt0rted/block-autosquash-commits-action@v2
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}