Skip to content

Added lychee config files #7

Added lychee config files

Added lychee config files #7

Workflow file for this run

name: Check Links In Pull Requests
on:
pull_request:
branches:
- main
paths:
- '**/*.md' # Only trigger workflow if any Markdown files change
jobs:
check-links:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout GitHub repo
uses: actions/checkout@v4
with:
fetch-depth: 0
# Step 2: Check out base branch and dump all links (no fragments)
- name: Check out base branch
run: git checkout ${{ github.event.pull_request.base.ref }}
- name: Dump all links from base branch (no fragments)
uses: lycheeverse/lychee-action@v2
with:
args: "--dump ."
output: ./existing-links.txt
continue-on-error: true
# Step 3: Stash untracked files and switch back to feature branch
- name: Stash untracked files
run: git stash push --include-untracked
- name: Check out feature branch
run: git checkout ${{ github.head_ref }}
- name: Apply stashed changes
run: git stash pop || true
# Step 4: Add base branch links to .lycheeignore
- name: Update ignore file
run: |
if [ -f "existing-links.txt" ]; then
cat existing-links.txt >> .lycheeignore
fi
# Step 5: Get changed Markdown files in the PR
- name: Get changed Markdown files
id: changed-files
run: |
files=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }} ${{ github.head_ref }} | grep '\.md$' || true)
echo "changed_files=$files" >> $GITHUB_ENV
# Step 6: Run Lychee on changed files only (with fragments)
- name: Run Lychee link checker
uses: lycheeverse/lychee-action@v2
with:
args: "--no-progress --include-fragments ${{ env.changed_files }}"
# Step 7: Provide a helpful failure message
- name: Helpful failure message
if: ${{ failure() }}
run: |
echo "::error::Link check failed! Please review the broken links reported above."
echo ""
echo "If certain links are valid but fail due to:"
echo "- CAPTCHA challenges"
echo "- IP blocking"
echo "- Authentication requirements"
echo "- Rate limiting"
echo ""
echo "Consider adding them to .lycheeignore to bypass future checks."
echo "Format: Add one URL pattern per line"
exit 1