# This Link Checker is run on all documentation files once per week.

# references:
# - https://github.com/lycheeverse/lychee-action
# - https://github.com/lycheeverse/lychee

name: Link Checker

on:
  push:
    branches:
      - develop
      - master
  pull_request:
    branches:
      - master
  workflow_dispatch:
  schedule:
    # * is a special character in YAML so you have to quote this string
    - cron: '30 8 * * *'

permissions: # added using https://github.com/step-security/secure-repo
  contents: read

jobs:
  link-checker:
    runs-on: ubuntu-latest
    permissions:
      # lychee only uses the GITHUB_TOKEN to avoid rate-limiting
      contents: read
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

      - name: Restore lychee cache
        uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
        with:
          path: .lycheecache
          key: cache-lychee-${{ github.sha }}
          restore-keys: cache-lychee-

      - name: Link Checker
        uses: lycheeverse/lychee-action@f613c4a64e50d792e0b31ec34bbcbba12263c6a6 # v2.3.0
        with:
          args: >-
            --config .github/lychee.toml
            packages/mermaid/src/docs/**/*.md
            README.md
            README.zh-CN.md
          fail: true
          jobSummary: true
        env:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
