Skip to content

chore: Add lychee link checker to validate docs URLs in CI #30

chore: Add lychee link checker to validate docs URLs in CI

chore: Add lychee link checker to validate docs URLs in CI #30

Workflow file for this run

name: 'Docs Link Check'
on:
pull_request:
schedule:
- cron: '0 4 * * *'
workflow_dispatch:
inputs:
mode:
description: 'Checks to run'
type: choice
options: [offline, online, both]
default: both
permissions:
contents: read
jobs:
offline:
if: github.event_name == 'pull_request' || github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'offline' || inputs.mode == 'both'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Offline check (relative links, self-repo links, anchors)
uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411
with:
args: --offline --include-fragments --config ./lychee.toml .
online-changed:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
fetch-depth: 2 # need HEAD^1 (the base parent) for the changed-files diff
- name: Collect changed markdown files
id: changed
run: |
files=$(git diff --name-only --diff-filter=d HEAD^1 HEAD -- '*.md' | tr '\n' ' ')
echo "files=$files" >> "$GITHUB_OUTPUT"
- name: Online check (changed files)
if: steps.changed.outputs.files != ''
uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411
with:
args: --config ./lychee.toml ${{ steps.changed.outputs.files }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
online-full:
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && (inputs.mode == 'online' || inputs.mode == 'both'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Online check (all docs)
uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411
with:
args: --config ./lychee.toml .
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify:
needs: [offline, online-full]
if: failure() && github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Notify Slack
uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"text": "${{ github.event.repository.name }}: nightly docs link check failed. ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}