name: Quality

on:
  pull_request:
  workflow_dispatch:

permissions:
  contents: read

jobs:
  quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
        with:
          fetch-depth: 0
      - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
        with:
          node-version: 22
          cache: npm
      - run: npm ci
      - name: Check the PR quality policy
        env:
          QUALITY_BASE_REF: ${{ github.event.pull_request.base.sha || 'origin/main' }}
        run: |
          dotbabel quality check \
            --profile pr \
            --base "$QUALITY_BASE_REF" \
            --allow-project-commands \
            --json > quality-report.json
      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
        if: always()
        with:
          name: quality-report
          path: quality-report.json
