-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add broken link check: general and pr
Signed-off-by: peppi-lotta <[email protected]>
- Loading branch information
1 parent
804242f
commit 89f2ba7
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Check Links | ||
on: | ||
workflow_call | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
issues: write | ||
|
||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
||
- name: Link Checker | ||
id: linkcheck | ||
uses: lycheeverse/lychee-action@f796c8b7d468feb9b8c0a46da3fac0af6874d374 # v2.2.0 | ||
with: | ||
args: | | ||
--user-agent "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0" | ||
--root-dir "$(pwd)/" | ||
--fallback-extensions "md" | ||
"./**/*.md" | ||
output: /tmp/lychee_output.md | ||
fail: false | ||
|
||
- name: Create Issue From File | ||
if: steps.linkcheck.outputs.exit_code != 0 | ||
uses: peter-evans/create-issue-from-file@e8ef132d6df98ed982188e460ebb3b5d4ef3a9cd # v5.0.1 | ||
with: | ||
title: Link Checker Report | ||
content-filepath: /tmp/lychee_output.md | ||
labels: | | ||
kind/bug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Check Links In Pull Requests | ||
permissions: {} | ||
|
||
on: | ||
workflow_call: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
check-links: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{github.event.pull_request.head.ref}} | ||
repository: ${{github.event.pull_request.head.repo.full_name}} | ||
|
||
- name: Checkout base branch | ||
run: git checkout ${{ github.event.pull_request.base.ref }} | ||
|
||
- name: Get list of changed Markdown files | ||
id: changed-files | ||
run: | | ||
git diff --name-only origin/${{ github.event.pull_request.base.ref }}...${{ github.head_ref }} -- '*.md' > changed-files.txt | ||
cat changed-files.txt | ||
- name: Switch to PR branch | ||
run: git checkout ${{ github.head_ref }} | ||
|
||
- name: Check links in changed files | ||
uses: lycheeverse/lychee-action@v2 | ||
with: | ||
failIfEmpty: false | ||
args: | | ||
--no-progress | ||
$(cat changed-files.txt | tr '\n' ' ') | ||
- name: Provide 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 |