name: Pull Request

on:
  pull_request:
    types:
      - opened
      - reopened
      - edited
      - synchronize

permissions:
  contents: read
  
jobs:
  commitlint:
    {{> jobYml jobName="Lint Commits" jobCheckout=(obj fetch-depth=0) }}
      - name: Run Commitlint on Commits
        id: commit
        continue-on-error: true
        run: {{ rootNpxPath }} --offline commitlint -V --from 'origin/$\{{ github.base_ref }}' --to $\{{ github.event.pull_request.head.sha }}
      - name: Run Commitlint on PR Title
        if: steps.commit.outcome == 'failure'
        env:
          PR_TITLE: $\{{ github.event.pull_request.title }}
        run: echo "$PR_TITLE" | {{ rootNpxPath }} --offline commitlint -V
