A GitHub action that checks that commit messages match a regex patter. The action is able to act on pull request and push events and check the pull request title and body or the commit message of the commits of a push.
On pull requests the title and body are concatenated delimited by two line breaks.
Designed to be very flexible in usage you can split checks into various workflows, using action types on pull request to listen on, define branches for pushes etc. etc.
More information about pattern
and flags
can be found in the
JavaScript reference.
flags
is optional and defaults to gm
.
name: 'Commit Message Check'
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
push:
branches:
- master
- 'releases/*'
jobs:
check-commit-message:
name: Check Commit Message
runs-on: ubuntu-latest
steps:
- name: Check Commit Type
uses: gsactions/commit-message-checker@v1
with:
pattern: '\[[^]]+\] .+$'
flags: 'gm'
error: 'Your first line has to contain a commit type like "[BUGFIX]".'
- name: Check Line Length
uses: gsactions/commit-message-checker@v1
with:
pattern: '^[^#].{74}'
error: 'The maximum line length of 74 characters is exceeded.'
- name: Check for Resolves / Fixes
uses: gsactions/commit-message-checker@v1
with:
pattern: '^.+(Resolves|Fixes): \#[0-9]+$'
error: 'You need at least one "Resolves|Fixes: #<issue number>" line.'
git clone https://github.com/gsactions/commit-message-checker.git
npm install
npm run build
That's it, just start editing the sources...
Below is a list of commands you will probably find useful during the development cycle.
Builds the package to the lib
folder.
Runs Prettier on .ts and .tsx files and fixes errors.
Runs Prettier on .ts and .tsx files without fixing errors.
Runs Eslint on .ts and .tsx files.
Bundles the package to the dist
folder.
Runs Jest test suites.
Runs all of the above commands.
This project is released under the terms of the MIT License