Skip to content

fix: properly redirect #723

fix: properly redirect

fix: properly redirect #723

Workflow file for this run

name: 🍈 Lychee
on: [pull_request]
concurrency:
group: lychee-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
check:
name: Check Links
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
- name: 🍈 Lychee Link Checker (First Run)
id: lychee
uses: lycheeverse/lychee-action@v2
with:
args: >-
--cache
--cache-exclude-status 429,500,502,503,504
--max-cache-age 5m
--verbose
--no-progress
--exclude '.*'
--timeout 20
--max-retries 8
--retry-wait-time 5
--include '^https://'
--exclude 'https://www.gnu.org'
--exclude 'https://docs.solidjs.com'
--accept 200,201,204,304,403,429
'./apps/docs/content'
output: lychee/out.md
fail: false
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:
args: >-
--cache
--cache-exclude-status 429,500,502,503,504
--max-cache-age 5m
--verbose
--no-progress
--exclude '.*'
--timeout 30
--max-retries 10
--retry-wait-time 10
--include '^https://'
--exclude 'https://www.gnu.org'
--exclude 'https://docs.solidjs.com'
--accept 200,201,204,304,403,429
'./apps/docs/content'
output: lychee/out-retry.md
fail: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: πŸ“ Clean up Lychee Report
if: ${{ always() && github.event.pull_request.head.repo.fork == false }}
run: |
# Use retry results if available, otherwise use first run results
if [ -f "lychee/out-retry.md" ]; then
REPORT_FILE="lychee/out-retry.md"
elif [ -f "lychee/out.md" ]; then
REPORT_FILE="lychee/out.md"
fi
if [ -n "$REPORT_FILE" ]; then
# Parse stats from lychee markdown table
TOTAL=$(grep 'Total' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
SUCCESS=$(grep 'Successful' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
ERRORS=$(grep 'Errors' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
REDIRECTS=$(grep 'Redirected' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
EXCLUDED=$(grep 'Excluded' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
TIMEOUTS=$(grep 'Timeouts' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
UNKNOWN=$(grep 'Unknown' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
UNSUPPORTED=$(grep 'Unsupported' "$REPORT_FILE" | grep -oE '\| [0-9]+ +\|' | grep -oE '[0-9]+' || echo "0")
# Extract errors section
ERRORS_SECTION=$(sed -n '/^## Errors/,/^## /p' "$REPORT_FILE" | sed '$d' | tail -n +2)
# Format errors section
FORMATTED_ERRORS=""
while IFS= read -r line; do
if [[ $line =~ ^### ]]; then
file=$(echo "$line" | sed 's/### Errors in //')
FORMATTED_ERRORS+="\n**\`$file\`**\n"
elif [[ $line =~ ^\* ]]; then
FORMATTED_ERRORS+="$line\n"
fi
done <<< "$ERRORS_SECTION"
# Create formatted output using echo statements
echo "## 🍈 Lychee Link Check Report" > lychee/formatted.md
echo "" >> lychee/formatted.md
echo "**$TOTAL links:** \`βœ… $SUCCESS OK\` | \`🚫 $ERRORS errors\` | \`πŸ”€ $REDIRECTS redirects\` | \`πŸ‘» $EXCLUDED excluded\`" >> lychee/formatted.md
echo "" >> lychee/formatted.md
if [ "$ERRORS" -eq 0 ]; then
echo "### βœ… All links are working!" >> lychee/formatted.md
else
echo "### ❌ Errors" >> lychee/formatted.md
echo -e "$FORMATTED_ERRORS" >> lychee/formatted.md
fi
echo "---" >> lychee/formatted.md
echo "" >> lychee/formatted.md
echo "<details>" >> lychee/formatted.md
echo "<summary>Full Statistics Table</summary>" >> lychee/formatted.md
echo "" >> lychee/formatted.md
echo "| Status | Count |" >> lychee/formatted.md
echo "|--------|-------|" >> lychee/formatted.md
echo "| βœ… Successful | $SUCCESS |" >> lychee/formatted.md
echo "| πŸ”€ Redirected | $REDIRECTS |" >> lychee/formatted.md
echo "| πŸ‘» Excluded | $EXCLUDED |" >> lychee/formatted.md
echo "| 🚫 Errors | $ERRORS |" >> lychee/formatted.md
echo "| β›” Unsupported | $UNSUPPORTED |" >> lychee/formatted.md
echo "| ⏳ Timeouts | $TIMEOUTS |" >> lychee/formatted.md
echo "| ❓ Unknown | $UNKNOWN |" >> lychee/formatted.md
echo "" >> lychee/formatted.md
echo "</details>" >> lychee/formatted.md
fi
- name: πŸ“ Comment Broken Links
if: ${{ always() && github.event.pull_request.head.repo.fork == false }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: lychee
path: lychee/formatted.md
- name: 🚫 Fail if broken links found
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