diff --git a/.github/workflows/conventional_commits.yml b/.github/workflows/conventional_commits.yml index 9778b0186ada4e84e76d39f6d83eb9f4af822e9b..b4187d66f3e2541fd4ba99a750e352fdf0748331 100644 --- a/.github/workflows/conventional_commits.yml +++ b/.github/workflows/conventional_commits.yml @@ -1,13 +1,26 @@ -name: Conventional Commits - +# Enforces conventional commits on pull requests +# Ref: https://github.com/marketplace/actions/conventional-pull-request +name: Conventional commits pull request on: pull_request: branches: [main] - + types: [opened, edited, synchronize] jobs: - build: - name: Conventional Commits + lint-pr: + if: "${{ !contains(github.event.pull_request.title, 'chore(main): release') }}" + name: Lint PR runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: webiny/action-conventional-commits@v1.1.0 + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Validate + uses: CondeNast/conventional-pull-request-action@v0.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + commitlintRulesPath: "./commitlint.config.js" + # if the PR contains a single commit, fail if the commit message and the PR title do not match + commitTitleMatch: "false" # default: 'true' + # if you squash merge PRs and enabled "Default to PR title for squash merge commits", you can disable all linting of commits + ignoreCommits: "false" # default: 'false' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 530abf4e8f6dfa6d0d8b84e29033848f5b6def88..6a80529022ae36491cbbb22511c1a93a0050351f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -61,3 +61,9 @@ repos: stages: - post-commit - push + + - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook + rev: v9.11.0 + hooks: + - id: commitlint + stages: [commit-msg] diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000000000000000000000000000000000000..f3291750177ab4c70a7f300959f4f59623839fad --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,8 @@ +module.exports = { + extends: ['@commitlint/config-conventional'], + rules: { + 'subject-case': [0, 'never'], + 'subject-max-length': [2, 'always', 60], + 'type-enum': [2, 'always', ['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'style', 'test']], + }, +};