name: generate

on:
  push:
    branches:
      - "main"
    paths:
      - ".github/workflows/generate.yml"
      - "www/*"
      - "cmd/*"
      - "internal/cmd/*"
      - "files/*"
  workflow_dispatch:

jobs:
  docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: stable
      - uses: arduino/setup-task@v2
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - run: "go install github.com/santhosh-tekuri/jsonschema/cmd/jv@latest"
      - run: task docs:releases
        env:
          GITHUB_TOKEN: ${{ secrets.GH_PAT }}
      - run: task docs:generate
      - run: task schema:generate
      - run: task schema:validate
      - uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: "docs: update cmd docs"
          branch: main
