Skip to content

Commit f28ccf3

Browse files
Check Broken links in Markdown files that are changed in the current PR
1 parent 0f6209a commit f28ccf3

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

.github/workflows/lychee-links.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
1-
name: Check for Broken Links
1+
name: Check Broken links in PR
22

33
on:
44
pull_request:
5-
workflow_dispatch:
65

76
jobs:
87
lychee:
9-
name: Broken Link Checker
108
runs-on: ubuntu-latest
9+
1110
steps:
12-
- name: Checkout code
11+
- name: Checkout PR code
1312
uses: actions/checkout@v4
1413

15-
- name: Run Lychee link checker
14+
- name: Get changed Markdown files
15+
id: changed-files
16+
run: |
17+
echo "Fetching changed markdown files..."
18+
files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '\.md$' || true)
19+
echo "Changed Markdown files: $files"
20+
echo "md_files<<EOF" >> $GITHUB_OUTPUT
21+
echo "$files" >> $GITHUB_OUTPUT
22+
echo "EOF" >> $GITHUB_OUTPUT
23+
24+
- name: Run Lychee only on internal links in changed .md files
25+
if: steps.changed-files.outputs.md_files != ''
1626
uses: lycheeverse/[email protected]
1727
with:
1828
args: >
1929
--verbose
2030
--exclude-mail
2131
--no-progress
2232
--exclude ^https?://
23-
'**/*.md'
33+
${{ steps.changed-files.outputs.md_files }}
2434
env:
2535
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)