Skip to content

Check links with Lychee #286

Check links with Lychee

Check links with Lychee #286

Workflow file for this run

name: Check links with Lychee
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
push:
paths:
- .lycheeignore
- .github/workflows/check-links.yml
- scripts/sort-lychee-output.py
jobs:
check-links:
runs-on: ubuntu-latest
env:
LYCHEE_INPUT_FILE: "links.txt"
LYCHEE_OUTPUT_FILE: "lychee/out.md"
steps:
- name: Restore lychee cache
id: restore-cache
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
submodules: true
- run: |
grep -rh "More information: " tldr/pages/ | sort -u > ${{ env.LYCHEE_INPUT_FILE }}
echo "Checking" $(wc -l < ${{ env.LYCHEE_INPUT_FILE }}) "links"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: links
path: ${{ env.LYCHEE_INPUT_FILE }}
- name: Lychee URL checker
uses: lycheeverse/lychee-action@1d97d84f0bc547f7b25f4c2170d87d810dc2fb2c # v2.4.0
id: lychee
continue-on-error: true
with:
jobSummary: false
args: >-
--cache
--verbose
--no-progress
--accept 100..=103,200..=299,429
--max-concurrency 25
--exclude-all-private
${{ env.LYCHEE_INPUT_FILE }}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Sort failed URLs alphabetically
run: python3 scripts/sort-lychee-output.py
- name: Upload Lychee output as GitHub Job Summary
run: cat ${{ env.LYCHEE_OUTPUT_FILE }} > $GITHUB_STEP_SUMMARY
- name: Find the last report issue open
if: github.repository == 'tldr-pages/tldr-maintenance' && github.ref == 'refs/heads/main'
uses: micalevisk/last-issue-action@0d40124cc99ac8601c2516007f0c98ef3d27537b # v2.3.0
id: last-issue
with:
state: open
labels: check links
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update last report open issue created
if: ${{ github.repository == 'tldr-pages/tldr-maintenance' && github.ref == 'refs/heads/main' && steps.lychee.outputs.exit_code != 0 }}
uses: peter-evans/create-issue-from-file@e8ef132d6df98ed982188e460ebb3b5d4ef3a9cd # v5.0.1
with:
title: Link checker report
content-filepath: ${{ env.LYCHEE_OUTPUT_FILE }}
issue-number: ${{ steps.last-issue.outputs.issue-number }}
labels: check links
- name: Close last report open issue
if: ${{ github.repository == 'tldr-pages/tldr-maintenance' && github.ref == 'refs/heads/main' && steps.lychee.outputs.exit_code == 0 && steps.last-issue.outputs.has-found == 'true' }}
run: gh issue close ${{ steps.last-issue.outputs.issue-number }}
- name: Save lychee cache
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
if: always()
with:
path: .lycheecache
key: ${{ steps.restore-cache.outputs.cache-primary-key }}