summaryrefslogtreecommitdiff
path: root/.github/workflows/commit-lint.yml
blob: 7fbd9a2a0cc5623ce102844b3027a82b87efca42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
name: First commit message adheres to guidelines

on: [pull_request]

env:
  NODE_VERSION: lts/*

permissions:
  contents: read

jobs:
  lint-commit-message:
    runs-on: ubuntu-latest
    steps:
      - name: Compute number of commits in the PR
        id: nb-of-commits
        run: |
          echo "plusOne=$((${{ github.event.pull_request.commits }} + 1))" >> $GITHUB_OUTPUT
          echo "minusOne=$((${{ github.event.pull_request.commits }} - 1))" >> $GITHUB_OUTPUT
      - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab  # v3.5.2
        with:
          fetch-depth: ${{ steps.nb-of-commits.outputs.plusOne }}
          persist-credentials: false
      - run: git reset HEAD^2
      - name: Install Node.js
        uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c  # v3.6.0
        with:
          node-version: ${{ env.NODE_VERSION }}
      - name: Validate commit message
        run: |
          echo "::add-matcher::.github/workflows/commit-lint-problem-matcher.json"
          git rev-parse HEAD~${{ steps.nb-of-commits.outputs.minusOne }} | xargs npx -q core-validate-commit --no-validate-metadata --tap