Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xt0rted/block-autosquash-commits-action
A Github Action to prevent merging pull requests containing autosquash commit messages.
https://github.com/xt0rted/block-autosquash-commits-action
github-actions prevent-merging squash-commits workflows
Last synced: 6 days ago
JSON representation
A Github Action to prevent merging pull requests containing autosquash commit messages.
- Host: GitHub
- URL: https://github.com/xt0rted/block-autosquash-commits-action
- Owner: xt0rted
- License: mit
- Created: 2019-03-04T03:59:40.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-08-26T23:51:55.000Z (5 months ago)
- Last Synced: 2024-12-17T10:03:02.167Z (29 days ago)
- Topics: github-actions, prevent-merging, squash-commits, workflows
- Language: JavaScript
- Homepage:
- Size: 524 KB
- Stars: 18
- Watchers: 3
- Forks: 13
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-actions - Block Autosquash Commits
- fucking-awesome-actions - Block Autosquash Commits
- awesome-workflows - Block Autosquash Commits
README
# Block Autosquash Commits Action
[![CI](https://github.com/xt0rted/block-autosquash-commits-action/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/xt0rted/block-autosquash-commits-action/actions/workflows/ci.yml)
[![CodeQL](https://github.com/xt0rted/block-autosquash-commits-action/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/xt0rted/block-autosquash-commits-action/actions/workflows/codeql-analysis.yml)A Github Action to prevent merging pull requests containing [autosquash](https://git-scm.com/docs/git-rebase#git-rebase---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
```yaml
on: pull_requestname: Pull Requests
jobs:
message-check:
name: Block Autosquash Commitsruns-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](https://help.github.com/en/articles/enabling-required-status-checks) rule for your action to block merging if it detects any `fixup!` or `squash!` commits.
### Control Permissions
If your repository is using [control permissions](https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/) you'll need to set `pull-request: read` on either the workflow or the job.
#### Workflow Config
```yaml
on: pull_requestname: Pull Request
permissions:
pull-requests: readjobs:
message-check:
name: Block Autosquash Commitsruns-on: ubuntu-latest
steps:
- name: Block Autosquash Commits
uses: xt0rted/block-autosquash-commits-action@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
```#### Job Config
```yaml
on: pull_requestname: Pull Request
jobs:
message-check:
name: Block Autosquash Commitsruns-on: ubuntu-latest
permissions:
pull-requests: readsteps:
- name: Block Autosquash Commits
uses: xt0rted/block-autosquash-commits-action@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
```