name: Link Check

on:
  push:
  pull_request:
  schedule:
    - cron: '0 6 * * *'   # daily at 06:00 UTC
  workflow_dispatch:

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

      - name: Check internal Markdown links
        uses: lycheeverse/lychee-action@v2
        with:
          args: >-
            --offline
            --no-progress
            "**/*.md"
          fail: true

  link-check-external:
    # External link check runs on schedule + manual trigger only.
    # Skipping push/PR avoids hammering external sites and CI flakes
    # when a target host has transient outage or rate-limit issues.
    if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Check external Markdown links
        uses: lycheeverse/lychee-action@v2
        with:
          args: >-
            --no-progress
            --max-concurrency 4
            --user-agent "Mozilla/5.0 (compatible; lychee-action; +https://github.com/lycheeverse/lychee-action)"
            "**/*.md"
          fail: false
          token: ${{ secrets.GITHUB_TOKEN }}
