This is a Github Action that ensures that your PR title matches the Conventional Commits spec.
This is helpful when you're using semantic-release with the Conventional Commits preset. When using the "Squash and merge" strategy, Github will suggest to use the PR title as the commit message. With this action you can validate that the PR title will lead to a correct commit message.
Examples for valid PR titles:
- fix: Correct typo.
- feat: Add support for Node 12.
- refactor!: Drop support for Node 6.
Note that since PR titles only have a single line, you have to use the !
syntax for breaking changes.
See Conventional Commits for more examples.
Github has support for draft pull requests, which will disable the merge button until the PR is marked as ready for merge.
However, this feature might be disabled for your repository. In this case you can use the special [WIP]
prefix to indicate that a pull request is work in progress and isn't ready to be merged. This will avoid the validation of the PR title and the pull request checks remain pending.
name: "Lint PR"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v1.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Note the usage of pull_request_target
as the event trigger is necessary for a fork-based workflow so the API token is valid for status reporting.