For checking the commit messages, a configuration file (commitlint.config.mjs
) with some rules is used, which can be individually adapted.
To find out what the rules are about and what rules can be used see:
https://github.com/conventional-changelog/commitlint/blob/master/docs/reference-rules.md
# get the correct commitlint configuration file
- name: Get commitlint config
run: |
curl https://raw.githubusercontent.com/fntsoftware/commitlint-config/main/cmd-commitlint.config.mjs \
-o commitlint.config.mjs
# use an commitlint github action for linting
- name: Check commit message
uses: wagoid/commitlint-github-action@v6
with:
configFile: commitlint.config.mjs
commitDepth: 1
<type>(<scope?>): <subject!>
<BLANK LINE>
<body?>
<BLANK LINE>
<footer?>
# install npm dependencies
npm ci
# check if installation was successfull (help message should be shown)
npx commitlint
echo "feat(scope): new feature" | npx commitlint --config cmd-commitlint.config.mjs
alternatively you can read multiline input from a file:
cat input.txt | npx commitlint --config cmd-commitlint.config.mjs
or check actual commit message and using a separate config file stored at different location:
npx commitlint --from=HEAD~1 --config cmd-commitlint.config.mjs