name: pr lint
on:
  workflow_dispatch:
  pull_request:
    types: [opened, reopened, synchronize, ready_for_review, edited]
jobs:
  enforce_title:
    name: pr lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Bun
        uses: oven-sh/setup-bun@v2
        with:
          scope: "@silencelaboratories"
          registry-url: "https://registry.npmjs.org"
          bun-version: "latest"

      - name: Install dependencies
        shell: bash
        run: bun install --frozen-lockfile
        env:
          VITE_SILENCE_LABS_NPM_TOKEN: ${{ secrets.VITE_SILENCE_LABS_NPM_TOKEN }}
          BUN_AUTH_TOKEN: ${{ secrets.VITE_SILENCE_LABS_NPM_TOKEN }}

      - name: Use commitlint to check PR title
        run: echo "${{ github.event.pull_request.title }}" | bun commitlint
