name: Links

on:
  workflow_dispatch:
  push:
    branches:
      - "release/**"
    paths:
      - "**.md"
      - "**.html"
      - "./.github/workflows/check-links.yml"
  pull_request:
    paths:
      - "**.md"
      - "**.html"
      - "./.github/workflows/check-links.yml"

jobs:
  linkChecker:
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout
        uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
        with:
          ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}

      - name: Link Checker
        uses: lycheeverse/lychee-action@ec3ed119d4f44ad2673a7232460dc7dff59d2421 # v1.8.0
        with:
          args: "--verbose --no-progress --max-concurrency 5 --exclude-path './internal/constellation/helm/charts/cilium' './**/*.md' './**/*.html'"
          fail: true
        env:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
