name: Definition-Lint

on:
  push:
    branches:
      - master
      - release-*
  workflow_dispatch: {}
  pull_request:
    branches:
      - master
      - release-*

permissions:
  contents: read

env:
  # Common versions
  GO_VERSION: '1.23.8'

jobs:
  definition-doc:
    runs-on: ubuntu-22.04
    steps:
      - name: Setup Go
        uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
        with:
          go-version: ${{ env.GO_VERSION }}

      - name: Checkout
        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
        with:
          submodules: true

      - name: Setup KinD
        uses: ./.github/actions/setup-kind-cluster
        with:
          name: linter

      - name: Definition Doc generate check
        run: |
          go build -o docgen hack/docgen/def/gen.go
          ./docgen --type=comp --force-example-doc --path=./comp-def-check.md
          ./docgen --type=trait --force-example-doc --path=./trait-def-check.md
          ./docgen --type=wf --force-example-doc --path=./wf-def-check.md --def-dir=./vela-templates/definitions/internal/workflowstep/
          ./docgen --type=policy --force-example-doc --path=./policy-def-check.md