|
| 1 | +name: π Lychee |
| 2 | + |
| 3 | +on: [pull_request] |
| 4 | + |
| 5 | +concurrency: |
| 6 | + group: lychee-${{ github.event.pull_request.number }} |
| 7 | + cancel-in-progress: true |
| 8 | + |
| 9 | +jobs: |
| 10 | + check-links: |
| 11 | + name: Check links |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + pull-requests: write |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: π Lychee Link Checker |
| 19 | + id: lychee |
| 20 | + uses: lycheeverse/lychee-action@v2 |
| 21 | + with: |
| 22 | + fail: false |
| 23 | + output: ../lychee/out.md |
| 24 | + args: > |
| 25 | + --cache |
| 26 | + --max-cache-age 3h |
| 27 | + --verbose |
| 28 | + --no-progress |
| 29 | + --accept 200,201,204,304,403,429 |
| 30 | + --timeout 20 |
| 31 | + --max-retries 5 |
| 32 | + --retry-wait-time 5 |
| 33 | + --max-concurrency 16 |
| 34 | + --exclude 'http://localhost.*' |
| 35 | + --exclude 'https://localhost.*' |
| 36 | + --exclude 'https://dev.mysql.com/.*' |
| 37 | + --exclude 'https://www.mysql.com/.*' |
| 38 | + --exclude 'https://www.gnu.org/.*' |
| 39 | + --exclude 'https://www.cockroachlabs.com/.*' |
| 40 | + --exclude '^/.*' |
| 41 | + './**/*.md' './**/*.mdx' |
| 42 | + workingDirectory: "content" |
| 43 | + env: |
| 44 | + GITHUB_TOKEN: ${{ secrets.github_token }} |
| 45 | + |
| 46 | + - name: π Clean up Lychee Report |
| 47 | + if: ${{ always() && github.event.pull_request.head.repo.fork == false }} |
| 48 | + run: | |
| 49 | + if [ -f "lychee/out.md" ]; then |
| 50 | + # Read the original output |
| 51 | + ORIGINAL=$(cat lychee/out.md) |
| 52 | + |
| 53 | + # Create formatted output |
| 54 | + cat > lychee/formatted.md << 'EOF' |
| 55 | + ## π Lychee Link Check Report |
| 56 | +
|
| 57 | + > **Note:** Links are cached for 3 hours to avoid unnecessary requests, and speed up consecutive runs. |
| 58 | +
|
| 59 | + ### π Results Overview |
| 60 | +
|
| 61 | + EOF |
| 62 | + |
| 63 | + # Append the original content with title replacement |
| 64 | + echo "$ORIGINAL" | sed 's/^# Summary$//' | sed 's/^## Summary$//' >> lychee/formatted.md |
| 65 | + fi |
| 66 | +
|
| 67 | + - name: π Comment Broken Links |
| 68 | + if: ${{ always() && github.event.pull_request.head.repo.fork == false }} |
| 69 | + uses: peter-evans/create-or-update-comment@v4 |
| 70 | + with: |
| 71 | + issue-number: ${{ github.event.pull_request.number }} |
| 72 | + body-path: lychee/formatted.md |
| 73 | + |
| 74 | + - name: π« Fail if broken links found |
| 75 | + if: ${{ steps.lychee.outputs.exit_code != 0 }} |
| 76 | + run: exit ${{ steps.lychee.outputs.exit_code }} |
0 commit comments