From 850a605ae111acb332b1390874479f37766e70a5 Mon Sep 17 00:00:00 2001 From: Abhayindia Date: Wed, 28 Oct 2026 20:49:29 +0900 Subject: [PATCH] Check the documentation links monthly with lychee --- .github/lychee.toml | 31 +++++++++++++++++++++++++ .github/workflows/linkcheck.yml | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 .github/lychee.toml create mode 100644 .github/workflows/linkcheck.yml diff --git a/.github/lychee.toml b/.github/lychee.toml new file mode 100644 index 000000000..82cc88252 --- /dev/null +++ b/.github/lychee.toml @@ -0,0 +1,31 @@ +scheme = ["http", "https"] +include_fragments = "anchor-only" +exclude_all_private = true +max_retries = 3 +timeout = 30 +host_concurrency = 4 +accept = ["200..=299", "403", "429"] + +extensions = ["cff", "html", "ipynb", "md", "py", "rst", "toml", "yaml", "yml"] +hidden = true + +exclude_path = [ + "(^|/)\\.git/", + "(^|/)docs/_build/", + "(^|/)\\.github/lychee\\.toml$", + "(^|/)docs/conf\\.py$", +] + +remap = [ + '^(https://github\.com/[^#]*)#.*$ $1', +] + +exclude = [ + '^https?://(www\.)?example\.(com|org)', + '^https://api\.github\.com/', + '/n$', + '\\n$', + '%7B', + '/%s$', + '^https://(www\.)?linkedin\.com/', +] diff --git a/.github/workflows/linkcheck.yml b/.github/workflows/linkcheck.yml new file mode 100644 index 000000000..150ced26b --- /dev/null +++ b/.github/workflows/linkcheck.yml @@ -0,0 +1,40 @@ +name: Link Check + +on: + schedule: + - cron: "0 3 1 * *" + workflow_dispatch: + pull_request: + paths: + - .github/workflows/linkcheck.yml + - .github/lychee.toml + +permissions: + contents: read + +jobs: + linkcheck: + if: github.repository_owner == 'casact' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 + with: + persist-credentials: false + + - name: Check links + id: lychee + uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 + with: + args: >- + --config .github/lychee.toml --no-progress + --root-dir "${{ github.workspace }}" . + fail: false + jobSummary: true + + - name: Fail on lychee errors + if: steps.lychee.outputs.exit_code != 0 && steps.lychee.outputs.exit_code != 2 + run: | + echo "::error::lychee exited with code $EXIT_CODE" + exit 1 + env: + EXIT_CODE: ${{ steps.lychee.outputs.exit_code }}