diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml index ebf433e..75b8494 100644 --- a/.github/workflows/commit-lint.yml +++ b/.github/workflows/commit-lint.yml @@ -1,10 +1,10 @@ on: push: branches: - - '*' # Runs on any push to any branch + - '*' pull_request: branches: - - '*' # Runs on any pull request targeting any branch + - '*' name: Lint commits permissions: @@ -14,16 +14,20 @@ jobs: lint-commits: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Fixup git permissions shell: bash run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - - uses: actions/setup-node@v4.1.0 + - uses: actions/setup-node@v4 with: node-version: 20 - name: Install commitlint dependencies run: npm install --save-dev @commitlint/cli @commitlint/config-conventional - - name: Check commit messages - run: npx commitlint --from HEAD~${{ github.event.pull_request.commits || 1 }} --to HEAD + - name: Check commit messages (PR) + if: github.event_name == 'pull_request' + run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose + - name: Check commit message (push) + if: github.event_name == 'push' + run: npx commitlint --from HEAD~1 --to HEAD --verbose