Skip to content

Check Links in Repository

This recipe demonstrates how to set up an automated workflow that will check all repository links once per day and create an issue in case of errors.

The workflow is triggered in three scenarios: Manual trigger via workflow_dispatch Repository dispatch events Automated schedule (runs daily at 18:00 UTC) The workflow executes the following steps: Checks out the repository using actions/checkout@v5 Runs the Lychee link checker (lycheeverse/lychee-action@v2) with fail: false to prevent workflow failure If any broken links are detected (exit code != 0), creates a new GitHub issue using peter-evans/create-issue-from-file@v6 The issue contains the detailed report from ./lychee/out.md Issues are labeled with “report” and “automated issue” The workflow requires write permissions for issues to create automated reports when broken links are found.

.github/workflows/check-links.yml
name: Links
on:
repository_dispatch:
workflow_dispatch:
schedule:
- cron: "00 18 * * *"
jobs:
linkChecker:
runs-on: ubuntu-latest
permissions:
issues: write # Required for peter-evans/create-issue-from-file
steps:
- uses: actions/checkout@v5
- name: Build site
uses: withastro/action@v4
with:
package-manager: pnpm@latest
- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v2
with:
args: --base-url dist --exclude-all-private dist
fail: false