name: cli-auth-smoke

on:
  schedule:
    - cron: "17 */6 * * *"
  push:
    branches: [main]
    paths:
      - ".github/workflows/cli-auth-smoke.yml"
      - "packages/petdex-cli/**"
      - "src/app/api/cli/**"
  workflow_dispatch:

permissions:
  contents: read

jobs:
  oauth-authorize:
    name: Production OAuth authorize smoke
    runs-on: ubuntu-latest
    timeout-minutes: 3

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: 24

      - name: Validate CLI OAuth client
        working-directory: packages/petdex-cli
        # This stops before any user sign-in. It only verifies that Clerk accepts
        # the public CLI OAuth client far enough to avoid invalid_client.
        run: node scripts/oauth-authorize-smoke.mjs
