Skip to content

Commit

Permalink
chore: Check commit messages as GitHub action
Browse files Browse the repository at this point in the history
- Since Standard Version isn't able to correctly identify what the new
  version of a package should be when the commit message begins with an
  unknown type, this new GitHub action will cause PRs to have a failing
  build when any commit contains an unsupported commit type.
  • Loading branch information
jordanleven committed Oct 26, 2020
1 parent 8daa06a commit 169ea29
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/check-commit-messages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Check Commit Message'

on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
push:
branches:
- master

jobs:
check-commit-message:
name: Check Commit Message
runs-on: ubuntu-latest
steps:
- name: Commit begins with supported commit type
uses: gsactions/commit-message-checker@v1
with:
pattern: '^(feat|fix|docs|style|refactor|test|chore).+'
error: 'Commit messages must begin with a valid commit type. See "Commit Style" under CONTRIBUTING.md for more details.'
excludeDescription: 'true'
excludeTitle: 'true'
checkAllCommitMessages: 'true'
accessToken: ${{ secrets.GITHUB_TOKEN }}
17 changes: 15 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,26 @@
- Assign a [sparkboxer][contributors] to review your PR

## Commit Style
We use [Conventional Commits] and [Standard Version] to automate versioning of this package. Commit messages must be prefixed with a valid commit type.
We use [Conventional Commits] and [Standard Version] to automate versioning of this package. Commit messages must be prefixed with a valid commit type and the commit type cannot be prefixed with any additional text.

Supported commit types include `feat`, `fix`, `docs`, `style`, `refactor`, and `test`.

Valid example:

Example:
```sh
feat: add new linting rule for ...
```

Invalid examples:

```sh
feature: add new linting rule for ...
```

```sh
:sparkles: feat: add new linting rule for ...
```

ℹ️ See the [Conventional Commits] page for further details on available commit types and how to handle breaking changes.

## Creating a Release
Expand Down

0 comments on commit 169ea29

Please sign in to comment.