Skip to content

Commit b3eb373

Browse files
feat: Add Broken Link Checker workflow for Markdown files (#1835)
1 parent df2e40a commit b3eb373

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Broken Link Checker
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**/*.md'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
markdown-link-check:
14+
name: Check Markdown Broken Links
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout Repo
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Get Added/Modified Markdown Files (PR only)
24+
id: changed-files
25+
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 != ''
34+
uses: lycheeverse/[email protected]
35+
with:
36+
args: >
37+
--verbose --exclude-mail --no-progress --exclude ^https?://
38+
${{ steps.changed-files.outputs.md_files }}
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Check Broken Links in Entire Repo (Manual)
43+
if: github.event_name == 'workflow_dispatch'
44+
uses: lycheeverse/[email protected]
45+
with:
46+
args: >
47+
--verbose --exclude-mail --no-progress --exclude ^https?://
48+
'**/*.md'
49+
output: lychee/out.md
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)