Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex to validate the commit message #523

Open
JobaDiniz opened this issue Apr 28, 2023 · 3 comments
Open

Regex to validate the commit message #523

JobaDiniz opened this issue Apr 28, 2023 · 3 comments

Comments

@JobaDiniz
Copy link

I did not know there was a conventional commit org! I was using my own conventional very similar borrowed from years ago somewhere.

Is there a regex that we can to check the commit message pattern following the conventional rules?

For example, I have this github action which uses gsactions/commit-message-checker@v2.

name: commit

on:
  pull_request:
    branches: [ develop ]

jobs:
  check-commit-message:
    name: check commit message
    runs-on: ubuntu-latest
    steps:
    - name: Check message against regex
      uses: gsactions/commit-message-checker@v2
      with:
        pattern: '(?:build|docs|refactor|test|fix|perf|chore|feat)(?:\(\w+\))?:\s[a-z]{1,2}.+'
        error: "The commit message must follow the commit messages guidelines"
        excludeDescription: 'true' # optional: this excludes the description body of a pull request
        excludeTitle: 'true' # optional: this excludes the title of a pull request
        checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request
        accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
@damianopetrungaro
Copy link
Member

Hey! There is this GitHub action I use often: https://github.com/webiny/action-conventional-commits

Do you think would that work for your use case?

@JobaDiniz
Copy link
Author

That's even better!

@thekaveman
Copy link

There's also a pre-commit hook you can add for validating commit messages at commit time: https://github.com/compilerla/conventional-pre-commit

Disclaimer: My company is the author of this hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants