Skip to content

Commit

Permalink
chore: Add commit message check
Browse files Browse the repository at this point in the history
Adds workflow to enforce our commit message format during pull requests
and pushing to master branch.
  • Loading branch information
arusso committed Apr 5, 2023
1 parent 68117e4 commit bd48d9e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/commit-message-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'Commit Message Check'
on:
pull_request: {}
pull_request_target: {}
push:
branches:
- master
- 'releases/*'

jobs:
check-commit-message:
name: Check Commit Message
runs-on: ubuntu-latest
steps:
- name: Check Commit Subject Prefix
uses: gsactions/commit-message-checker@v2
with:
pattern: '(fix|feat|chore|docs|test|refactor|revert|test)(\[[^]]+\])?: .*$'
flags: 'gm'
error: >-
Your first line is missing a valid subject prefix. See Commit
Messages section of CONTRIBUTING doc
checkAllCommitMessages: 'true'
excludeTitle: 'true'
excludeDescription: 'true'
accessToken: ${{ secrets.GITHUB_TOKEN }}

- name: Check Line Length
uses: gsactions/commit-message-checker@v2
with:
pattern: '^(?![^#].{74})'
error: 'The maximum line length of 74 characters is exceeded.'
excludeDescription: 'true'
excludeTitle: 'true'
checkAllCommitMessages: 'true'
accessToken: ${{ secrets.GITHUB_TOKEN }}

# Maybe in the future?
# - name: Check for Resolves / Fixes
# uses: gsactions/commit-message-checker@v2
# with:
# pattern: '^.+(Resolves|Fixes): \#[0-9]+$'
# error: 'You need at least one "Resolves|Fixes: #<issue number>" line.'
5 changes: 5 additions & 0 deletions MAINTAINING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@ those that start with `fix:` will be grouped into a "Bug fixes" section. Commits
that begin with `chore:` or `docs:` will be excluded, and all others will be
added to an "Others" section in the changelog.

The [commit-message-check](./.github/workflows/commit-message-check.yaml)
workflow enforces this format during pull requests. When pushing directly to
master this will not prevent the commit from being pushed but the check will
still fail.

For more details on commit message formatting see the
[CONTRIBUTING](./CONTRIBUTING.md) doc.

0 comments on commit bd48d9e

Please sign in to comment.