name: Commit Lint on: push: branches: - main pull_request: branches: - main concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: contents: read jobs: commitlint: name: Validate Commit Messages runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v6 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: "20" cache: "npm" - name: Install dependencies run: npm ci - name: Lint commit messages shell: bash run: | if [[ "${{ github.event_name }}" == "pull_request" ]]; then FROM="${{ github.event.pull_request.base.sha }}" TO="${{ github.event.pull_request.head.sha }}" else FROM="${{ github.event.before }}" TO="${{ github.sha }}" fi if [[ "$FROM" == "0000000000000000000000000000000000000000" ]]; then npx commitlint --last --verbose else npx commitlint --from "$FROM" --to "$TO" --verbose fi