name: Check docs for broken links

on:
  workflow_run:
    workflows: ["mintlify docs"]
    types:
      - completed
    branches:
      - main

permissions:
  contents: read

jobs:
  check-broken-link:
    if: |
      github.event.workflow_run.conclusion == 'success' &&
      github.event.workflow_run.head_branch == 'main'
    runs-on: ubuntu-latest
    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://docs.ag2.ai"
