-
Notifications
You must be signed in to change notification settings - Fork 22
🌱 Add broken link check: pr and scheduled #966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
peppi-lotta
wants to merge
1
commit into
metal3-io:main
Choose a base branch
from
Nordix:peppi-lotta/add-link-check-work-flows
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,67 @@ | ||||||
name: Check Links In Pull Requests | ||||||
|
||||||
on: | ||||||
pull_request: | ||||||
types: [opened, edited, reopened, synchronize, ready_for_review] | ||||||
workflow_call: | ||||||
|
||||||
permissions: {} | ||||||
|
||||||
concurrency: | ||||||
group: ${{ github.workflow }}-${{ github.ref }} | ||||||
cancel-in-progress: true | ||||||
|
||||||
jobs: | ||||||
check-links-pr: | ||||||
runs-on: ubuntu-latest | ||||||
|
||||||
steps: | ||||||
- name: Clone repository | ||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||||||
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 | ||||||
if [ -s changed-files.txt ]; then | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
echo "Changed md files found" | ||||||
echo "foundFiles=true" >> $GITHUB_ENV | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
fi | ||||||
|
||||||
- name: Switch to PR branch | ||||||
run: git checkout ${{ github.head_ref }} | ||||||
|
||||||
- name: Check links in changed files | ||||||
if: env.foundFiles == 'true' | ||||||
uses: lycheeverse/lychee-action@f796c8b7d468feb9b8c0a46da3fac0af6874d374 # v2.2.0 | ||||||
env: | ||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||
with: | ||||||
failIfEmpty: false | ||||||
args: | | ||||||
--no-progress | ||||||
--github-token | ||||||
$(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 |
This file contains hidden or 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,47 @@ | ||
name: Scheduled Check Links | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 0 1 * *" | ||
repository_dispatch: | ||
# run manually | ||
types: [check-links] | ||
workflow_call: | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
check-links: | ||
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 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
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" | ||
--github-token | ||
"./**/*.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 hidden or 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,3 @@ | ||
https://jenkins.nordix.org/log/GHPRB/ | ||
https://jenkins.nordix.org/ghprbhook/ | ||
https://prow.apps.test.metal3.io/hook |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.