Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 52 additions & 9 deletions .github/workflows/lychee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: 🍈 Lychee Link Checker
- name: 🍈 Lychee Link Checker (First Run)
id: lychee
uses: lycheeverse/lychee-action@v2
with:
fail: false
output: ../lychee/out.md
args: >
--cache
--cache-exclude-status 429,500,502,503,504
--max-cache-age 5m
--verbose
--no-progress
Expand All @@ -39,23 +40,58 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.github_token }}

- name: 🔄 Retry Lychee Link Checker (Second Run for Timeouts)
id: lychee-retry
if: ${{ always() && steps.lychee.outputs.exit_code != 0 }}
uses: lycheeverse/lychee-action@v2
with:
fail: false
output: ../lychee/out-retry.md
args: >
--cache
--max-cache-age 5m
--verbose
--no-progress
--accept 200,201,204,304,403,429
--cache-exclude-status 429,500,502,503,504
--timeout 30
--max-retries 10
--retry-wait-time 10
--exclude 'http://localhost.*'
--exclude 'https://localhost.*'
--exclude 'https://cockroachlabs.com'
--exclude '^/.*'
'./**/*.md' './**/*.mdx'
workingDirectory: "content"
env:
GITHUB_TOKEN: ${{ secrets.github_token }}

- name: 📝 Clean up Lychee Report
if: ${{ always() && github.event.pull_request.head.repo.fork == false }}
run: |
if [ -f "lychee/out.md" ]; then
# Use retry results if available, otherwise use first run results
if [ -f "lychee/out-retry.md" ]; then
REPORT_FILE="lychee/out-retry.md"
NOTE="Links are cached for 5 minutes. Failed links (timeouts, rate limits) are retried in a second run with longer timeout."
elif [ -f "lychee/out.md" ]; then
REPORT_FILE="lychee/out.md"
NOTE="Links are cached for 5 minutes to avoid unnecessary requests, and speed up consecutive runs."
fi

if [ -n "$REPORT_FILE" ]; then
# Read the original output
ORIGINAL=$(cat lychee/out.md)
ORIGINAL=$(cat "$REPORT_FILE")

# Create formatted output
cat > lychee/formatted.md << 'EOF'
cat > lychee/formatted.md << EOF
## 🍈 Lychee Link Check Report

> **Note:** Links are cached for 5 minutes to avoid unnecessary requests, and speed up consecutive runs.
> **Note:** $NOTE

### 📊 Results Overview

EOF

# Append the original content with title replacement
echo "$ORIGINAL" | sed 's/^# Summary$//' | sed 's/^## Summary$//' >> lychee/formatted.md
fi
Expand All @@ -68,5 +104,12 @@ jobs:
body-path: lychee/formatted.md

- name: 🚫 Fail if broken links found
if: ${{ steps.lychee.outputs.exit_code != 0 }}
run: exit ${{ steps.lychee.outputs.exit_code }}
if: ${{ steps.lychee-retry.conclusion == 'success' && steps.lychee-retry.outputs.exit_code != 0 || steps.lychee-retry.conclusion == 'failure' }}
run: |
if [ "${{ steps.lychee-retry.conclusion }}" == "success" ]; then
echo "Failing based on retry run results"
exit ${{ steps.lychee-retry.outputs.exit_code }}
else
echo "Failing based on first run results"
exit ${{ steps.lychee.outputs.exit_code }}
fi
Loading