name: Links

on:
  push:
    branches:
      - main
    paths:
      - docs/**
      - README.md
      - RELEASING.md
      - .github/workflows/links.yml
  pull_request:
    paths:
      - docs/**
      - README.md
      - RELEASING.md
      - .github/workflows/links.yml
  workflow_dispatch:

jobs:
  check-links:
    runs-on: ubuntu-24.04-arm
    if: github.event.repository.fork == false
    steps:
      - uses: actions/checkout@v7
      - uses: gradle/actions/setup-gradle@v6
        with:
          cache-read-only: true
      # This is required for action-linkspector to work with API links.
      - run: ./gradlew dokkaGenerate
      - name: Mkdocs build validation
        run: |
          # Don't cache it to track updates.
          pip install mkdocs-material
          mkdocs build --strict
      - uses: umbrelladocs/action-linkspector@v1
        with:
          reporter: github-pr-check
          fail_on_error: true
          filter_mode: nofilter
          fail_level: any
