From 6f2ae74cb01c4bd135dbe686eddd5097d2c6cde5 Mon Sep 17 00:00:00 2001 From: Hazel Virdo Date: Wed, 14 Jan 2026 16:17:45 -0500 Subject: [PATCH 1/2] implement caching? --- .github/workflows/link-check-cache.yml | 38 ++++++++++++++++++++++++++ .github/workflows/link-check.yml | 12 +++++++- lychee.toml | 2 +- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/link-check-cache.yml diff --git a/.github/workflows/link-check-cache.yml b/.github/workflows/link-check-cache.yml new file mode 100644 index 000000000..0760a80ee --- /dev/null +++ b/.github/workflows/link-check-cache.yml @@ -0,0 +1,38 @@ +# Cache link check results on each commit to main. + +name: Lychee Cache Update + +on: + push: + branches: [main] + +jobs: + lychee-cache-update: + name: Lychee Link Checking + runs-on: ubuntu-latest + + steps: + - name: Check out repo + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + + - name: Restore Lychee cache + id: restore-cache + uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: .lycheecache + key: cache-lychee-${{ github.event.push.before }} + restore-keys: cache-lychee- + + - name: Run Lychee + uses: lycheeverse/lychee-action@a8c4c7cb88f0c7386610c35eb25108e448569cb0 # v2.7.0 + with: + format: markdown + jobSummary: true + args: > + -c lychee.toml --root-dir "$(pwd)" **/*.mdx + + - name: Update Lychee cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: .lycheecache + key: cache-lychee-${{ github.event.push.after }} diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml index 34c1bf37f..4669dcfcc 100644 --- a/.github/workflows/link-check.yml +++ b/.github/workflows/link-check.yml @@ -1,7 +1,8 @@ +# Check links on changed MDX files in PRs. + name: Lychee Link Checking on: - # Run on PRs targeting main that change content files. pull_request: branches: [main] paths: ['**/*.mdx?'] @@ -24,8 +25,16 @@ jobs: files: | **.mdx + - name: Restore Lychee cache + uses: actions/cache@v5 + with: + path: .lycheecache + key: cache-lychee-${{ github.event.pull_request.base.sha }} + restore-keys: cache-lychee- + - name: Run Lychee uses: lycheeverse/lychee-action@a8c4c7cb88f0c7386610c35eb25108e448569cb0 # v2.7.0 + if: steps.changed-mdx-files.any_changed == 'true' with: fail: false format: markdown @@ -37,5 +46,6 @@ jobs: - name: Comment on PR with link check results uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4 + if: steps.changed-mdx-files.any_changed == 'true' with: path: lychee/out.md diff --git a/lychee.toml b/lychee.toml index 561b596c4..2e482439b 100644 --- a/lychee.toml +++ b/lychee.toml @@ -11,9 +11,9 @@ include_verbatim = false # Don't check links inside code blocks exclude_all_private = true # Exclude link local, loopback, and private IPs. # Cache only successful results to avoid re-checking valid links. -# TODO: Update GitHub Action to use the cache cache = true cache_exclude_status = "300.." +max_cache_age = "7d" # Set a root dir so Lychee can resolve relative links to URIs, even though we # exclude relative links in the actual check. From d2783c5bd32788265419251891570960bd508125 Mon Sep 17 00:00:00 2001 From: Hazel Virdo Date: Wed, 14 Jan 2026 17:17:12 -0500 Subject: [PATCH 2/2] fix ref --- .github/workflows/link-check-cache.yml | 7 ++++--- .github/workflows/link-check.yml | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/link-check-cache.yml b/.github/workflows/link-check-cache.yml index 0760a80ee..76f3e207b 100644 --- a/.github/workflows/link-check-cache.yml +++ b/.github/workflows/link-check-cache.yml @@ -20,19 +20,20 @@ jobs: uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 with: path: .lycheecache - key: cache-lychee-${{ github.event.push.before }} + key: cache-lychee-${{ github.event.before }} restore-keys: cache-lychee- - name: Run Lychee uses: lycheeverse/lychee-action@a8c4c7cb88f0c7386610c35eb25108e448569cb0 # v2.7.0 with: + fail: false format: markdown jobSummary: true args: > - -c lychee.toml --root-dir "$(pwd)" **/*.mdx + -c lychee.toml --root-dir "$(pwd)" './**/*.mdx' - name: Update Lychee cache uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 with: path: .lycheecache - key: cache-lychee-${{ github.event.push.after }} + key: cache-lychee-${{ github.event.after }} diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml index 4669dcfcc..da5c518a0 100644 --- a/.github/workflows/link-check.yml +++ b/.github/workflows/link-check.yml @@ -26,7 +26,8 @@ jobs: **.mdx - name: Restore Lychee cache - uses: actions/cache@v5 + uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + if: steps.changed-mdx-files.outputs.any_changed == 'true' with: path: .lycheecache key: cache-lychee-${{ github.event.pull_request.base.sha }} @@ -34,7 +35,7 @@ jobs: - name: Run Lychee uses: lycheeverse/lychee-action@a8c4c7cb88f0c7386610c35eb25108e448569cb0 # v2.7.0 - if: steps.changed-mdx-files.any_changed == 'true' + if: steps.changed-mdx-files.outputs.any_changed == 'true' with: fail: false format: markdown @@ -46,6 +47,6 @@ jobs: - name: Comment on PR with link check results uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4 - if: steps.changed-mdx-files.any_changed == 'true' + if: steps.changed-mdx-files.outputs.any_changed == 'true' with: path: lychee/out.md