name: Run pre-commit (PR)

on: pull_request

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  pre-commit:
    runs-on: ubuntu-24.04
    timeout-minutes: 20
    steps:
    - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
      with:
        fetch-depth: 0

    - name: Setup Tools
      uses: ./.github/actions/setup-tools

    - name: Setup NPM Packages
      uses: ./.github/actions/setup-npm

    - name: Lint PR Commits
      run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose

    - name: Run pre-commit
      uses: egose/actions/precommit@d0de96cd40ac3aa9b42cf7f6363bd374eced26e4
      with:
        config: .pre-commit-config.yaml
        commit-on-push: false
