name: Check Documentation Broken Links

on:
  pull_request:
    paths:
      - "docs/**"
      - "docs.json"
  push:
    branches:
      - main
    paths:
      - "docs/**"
      - "docs.json"
  workflow_dispatch:

jobs:
  check-links:
    name: Check broken links
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

      - name: Set up Node
        uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
        with:
          node-version: "22"

      - name: Install Mintlify CLI
        run: npm i -g mintlify

      - name: Run broken link checker
        run: |
          # Auto-answer the prompt with yes command
          yes "" | mintlify broken-links || test $? -eq 141
        working-directory: ./docs
