name: Documentation Workflows

permissions:
  contents: read

on:
  pull_request:
  merge_group:
jobs:
  ensure-docs-generated:
    name: Ensure docs are generated
    runs-on: "${{ vars.RUNS_ON || 'ubuntu-latest' }}"
    steps:
      # Checkout should always be before setup-go to ensure caching is working
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
        with:
          go-version: stable
      - name: Generate code
        run: go run ./cmd/scw-doc-gen
        env:
          # We need this to enable autocomplete documentation generation default
          SHELL: /bin/bash
      - name: Exit 1 if not empty
        run: git diff --exit-code
  markdown-link-check:
    runs-on: "${{ vars.RUNS_ON || 'ubuntu-latest' }}"
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - uses: gaurav-nelson/github-action-markdown-link-check@3c3b66f1f7d0900e37b71eca45b63ea9eedfce31 # 1.0.17
        with:
          use-quiet-mode: 'yes'
          use-verbose-mode: 'yes'
          config-file: '.markdownlinkcheck.json'
          folder-path: 'docs'
          file-extension: '.md'
