name: Check mkdocs for broken links

on:
  workflow_run:
    types:
      - completed
    workflows: ["pages-build-deployment"]

jobs:
  check-broken-link:
    name: Check mkdocs for broken links
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v5

      - name: Setup Go
        uses: actions/setup-go@v5

      - name: Install muffet
        run: go install github.com/raviqqe/muffet/v2@latest

      - name: Check for broken links
        run: ./scripts/broken-links-check.sh --url "https://ag2ai.github.io/ag2"
