diff --git a/.github/workflows/conventional_commits.yml b/.github/workflows/conventional_commits.yml index 02939fc7..fb902cfb 100644 --- a/.github/workflows/conventional_commits.yml +++ b/.github/workflows/conventional_commits.yml @@ -1,28 +1,27 @@ # Enforces conventional commits on pull requests # Ref: https://github.com/marketplace/actions/conventional-pull-request - -name: Conventional Commits - +name: Conventional commits pull request on: pull_request: branches: [main] types: [opened, edited, synchronize] - jobs: - build: + lint-pr: if: "${{ !contains(github.event.pull_request.title, 'chore(main): release') }}" - name: Conventional Commits + name: Lint PR runs-on: ubuntu-latest + timeout-minutes: ${{ fromJSON(vars.DEFAULT_JOB_TIMEOUT_MINUTES) }} steps: - - uses: actions/checkout@v3 - - name: Install commitlint - run: | - npm install @commitlint/cli @commitlint/config-conventional - - name: Fetch merge commit message - id: merge_commit - run: | - MERGE_COMMIT_MESSAGE=$(git log --merges -n 1 --pretty=format:"%s") - echo "::set-output name=message::$MERGE_COMMIT_MESSAGE" - - name: Validate merge commit message - run: | - echo "${{ steps.merge_commit.outputs.message }}" | npx commitlint + - 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 530abf4e..6a805290 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 index 3074fb28..f3291750 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,7 +1,7 @@ module.exports = { extends: ['@commitlint/config-conventional'], rules: { - 'subject-case': [2, 'always', 'sentence-case'], + 'subject-case': [0, 'never'], 'subject-max-length': [2, 'always', 60], 'type-enum': [2, 'always', ['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'style', 'test']], },