Quickly check links in Markdown, HTML, and text files using lychee.
When used in conjunction with Create Issue From File, issues will be created when the action finds link problems.
Here is a full example of a Github workflow file.
It will check all repository links once per day and create an issue in case of errors.
Save this under .github/workflows/links.yml
:
name: Links
on:
repository_dispatch:
workflow_dispatch:
schedule:
- cron: "00 18 * * *"
jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Link Checker
uses: lycheeverse/[email protected]
with:
args: --verbose --no-progress **/*.md **/*.html
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Create Issue From File
uses: peter-evans/create-issue-from-file@v2
with:
title: Link Checker Report
content-filepath: ./lychee/out.md
labels: report, automated issue
This action uses lychee for link checking.
lychee arguments can be passed to the action via the args
parameter.
- name: Link Checker
uses: lycheeverse/[email protected]
with:
args: --verbose --no-progress *.md
See lychee's documentation for all possible arguments.
Issues with links will be written to a file containing the error report.
The default path is lychee/out.md
. The path and filename may be overridden with the following variable:
LYCHEE_OUT
- The path to the output file for the Markdown error report
To create a failing check when there are link errors, you can use the exit_code
output from the action as follows.
on: push
jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: lychee Link Checker
id: lychee
uses: lycheeverse/[email protected]
- name: Fail if there were link errors
run: exit ${{ steps.lychee.outputs.exit_code }}
See lychee's Troubleshooting Guide for solutions to common link-checking problems.
A full CI run to scan 576 links takes approximately 1 minute for the analysis-tools-dev/static-analysis repository.
This action is based on peter-evans/link-checker and uses lychee (written in Rust) instead of liche (written in Go) for link checking. For a comparison of both tools, check out this comparison table.
lychee is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.