Action to validate commits follow the guidelines
In your workflow you first need to checkout you repository and then run the action. The action will fail if the commit messages do not follow the guidelines.
Refer to the following example:
name: check commit message
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
-name: Checkout
uses: actions/checkout@v4
-name: Check commit message
uses: YingHongBin/commit-message-validator@version
with:
scope-values: 'scope1, scope2'Customized scope values, default undifined, means any scope would be denied. If you want to use customized scope values, you can set the values in the scope-values input. The values should be separated by comma. Wildcard is acceptable if scope-values has been set.
Commit Message format as follows
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
Must be one of the following:
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing or correcting existing tests
- chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
Scope is optional. Scope must be a word or wildcard which means change affects more than a single scope.
Must satisfy following rules:
- Less than 80 characters
- Do not start or end with space
- Do not cpatialize first letter
- Do not end with a period
Body is optional. Body must satisfy following rules:
- Paragraphs must be capitalized
- Lines do not start or end with space
- Lines must be wrapped at 100 characters
Footer is optional. If the last paragraph start with close or fix, it is considered as footer. Footer must satisfy following rules:
- Only use
closeorfixas keywords - Format like
close #{issue_number}orfix #{issue_number} - Close multi issue in one line like
close #{issue_number}, close #{issue_number}, no additional space in the line.
If the commit is a merge commit from merge pull request in github, the commit message header line must be Merge pull request #{pull_request_number} from {branch_name}, which is default format from github.