Skip to content

fix: Test new pr

fix: Test new pr #47

name: Check Links In Pull Requests
on:
pull_request:
paths:
- '**/*.md'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-links:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Git
run: git fetch origin ${{ github.base_ref }}
- name: Get added/modified Markdown files
id: changed-files
run: |
files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '\.md$' || true)
echo "md_files<<EOF" >> $GITHUB_OUTPUT
echo "$files" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Dump base branch links into ignore file
if: steps.changed-files.outputs.md_files != ''
run: |
git checkout origin/${{ github.base_ref }}
mkdir -p .lychee
lychee --dump --include-fragments ${{ steps.changed-files.outputs.md_files }} > .lychee/ignore.txt || true
- name: Checkout PR branch again
run: git checkout ${{ github.head_ref }}
- name: Run lychee on PR changes
if: steps.changed-files.outputs.md_files != ''
uses: lycheeverse/[email protected]
with:
args: >
--no-progress --include-fragments
--max-concurrency 4
--exclude-mail
--accept 200,429
--ignore-file .lychee/ignore.txt
${{ steps.changed-files.outputs.md_files }}
failIfEmpty: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Provide helpful message on failure
if: failure()
run: |
echo "::error::Link check failed! Please review broken links above."
echo "If some links are false positives (e.g. behind auth, CAPTCHA),"
echo "you can add them to a .lycheeignore or adjust the check."
exit 1
- name: Check Broken Links in Entire Repo (Manual)
if: github.event_name == 'workflow_dispatch'
uses: lycheeverse/[email protected]
with:
args: >
--verbose --exclude-mail --no-progress --exclude ^https?://
'**/*.md'
failIfEmpty: false
output: lychee/out.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}