Skip to content

Check links with Lychee #115

Check links with Lychee

Check links with Lychee #115

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@v4
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-
- uses: actions/checkout@v4
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@v4
with:
name: links
path: ${{ env.LYCHEE_INPUT_FILE }}
- name: Lychee URL checker
uses: lycheeverse/lychee-action@v2
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@v2
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@v5
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@v4
if: always()
with:
path: .lycheecache
key: ${{ steps.restore-cache.outputs.cache-primary-key }}