name: Markdown Link Check

on:
  push:
    branches: [main]
    paths:
      - 'docs/**'
      - '**.md'
  pull_request:
    branches: [main]
    paths:
      - 'docs/**'
      - '**.md'

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

      - name: Run lychee link checker
        uses: lycheeverse/lychee-action@v1
        with:
          args: --verbose --no-progress --exclude 'mailto:*' --exclude 'https://dashboard.aitbc.io/*' --exclude 'https://aitbc.bubuit.net/admin/*' --exclude 'https://aitbc.bubuit.net/api/*' --exclude 'https://docs.aitbc.bubuit.net/*' --exclude 'https://aitbc.io/*' --exclude 'http://localhost:*' --exclude 'http://aitbc.keisanki.net:*' --exclude 'https://docs.aitbc.net/*' --exclude-file .lycheeignore 'docs/**/*.md' '**.md'
          fail: true

      - name: Upload link check results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: link-check-results
          path: lychee/out.md
