name: Docs link check

# Runs on PRs that touch any markdown under docs/. Fails if a link is dead
# (excluding localhost and private hosts — see .markdown-link-check.json).

on:
  pull_request:
    paths:
      - 'docs/**/*.md'
      - '.markdown-link-check.json'
      - '.github/workflows/docs-link-check.yml'

permissions:
  contents: read
  pull-requests: read

jobs:
  link-check:
    name: Markdown link check
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Find changed markdown files
        id: changed
        uses: tj-actions/changed-files@2d756ea4c53f7f6b397767d8723b3a10a9f35bf2 # v44
        with:
          files: docs/**/*.md

      - name: Run markdown-link-check on changed files
        if: steps.changed.outputs.any_changed == 'true'
        uses: gaurav-nelson/github-action-markdown-link-check@499c1e7f3637c131334fa8e937c45144f79d72d2 # v1
        with:
          use-quiet-mode: 'yes'
          use-verbose-mode: 'yes'
          config-file: '.markdown-link-check.json'
          file-path: ${{ steps.changed.outputs.all_changed_files }}
          base-branch: ${{ github.base_ref }}
          check-modified-files-only: 'yes'
