Skip to content

Commit 52b04b3

Browse files
Update Broken-links-checker-final.yml
1 parent 9ba7b58 commit 52b04b3

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

.github/workflows/Broken-links-checker-final.yml

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,46 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222

23-
- name: Get Added/Modified Markdown Files (PR only)
24-
id: changed-files
23+
# For pull request: Get only changed markdown files
24+
- name: Get changed markdown files (PR only)
25+
id: changed-markdown-files
2526
if: github.event_name == 'pull_request'
26-
run: |
27-
git fetch origin ${{ github.base_ref }}
28-
files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '\.md$' || true)
29-
echo "md_files<<EOF" >> $GITHUB_OUTPUT
30-
echo "$files" >> $GITHUB_OUTPUT
31-
echo "EOF" >> $GITHUB_OUTPUT
32-
- name: Check Broken Links in Added/Modified Files (PR)
33-
if: github.event_name == 'pull_request' && steps.changed-files.outputs.md_files != ''
27+
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46
28+
with:
29+
files: |
30+
**.md
31+
docs/**.md
32+
33+
# For PR: Check broken links only in changed files
34+
- name: Check Broken Links in Changed Markdown Files
35+
id: lychee-check-pr
36+
if: github.event_name == 'pull_request' && steps.changed-markdown-files.outputs.any_changed == 'true'
3437
uses: lycheeverse/[email protected]
3538
with:
3639
args: >
3740
--verbose --exclude-mail --no-progress --exclude ^https?://
38-
${{ steps.changed-files.outputs.md_files }}
41+
${{ steps.changed-markdown-files.outputs.all_changed_files }}
3942
failIfEmpty: false
4043
env:
4144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4245

43-
- name: Check Broken Links in Entire Repo (Manual)
46+
# For manual trigger: Check all markdown files in repo
47+
- name: Check Broken Links in All Markdown Files (Manual Trigger)
48+
id: lychee-check-manual
4449
if: github.event_name == 'workflow_dispatch'
4550
uses: lycheeverse/[email protected]
4651
with:
4752
args: >
4853
--verbose --exclude-mail --no-progress --exclude ^https?://
49-
'**/*.md'
54+
**/*.md
5055
failIfEmpty: false
51-
output: lychee/out.md
5256
env:
5357
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
59+
# Show warning on failure (PR or manual)
60+
- name: Show warning if link check failed
61+
if: failure()
62+
run: |
63+
echo "::warning ::❌ Broken links were found."
64+
echo "::warning ::🔎 Please review and fix them if possible."
65+
echo "::warning ::✅ If these are acceptable or false positives, the PR can still be merged (if the workflow is not required)."

0 commit comments

Comments
 (0)