Skip to content

Commit fc4e2a2

Browse files
feat: Add Broken Link Checker workflow for Markdown files (#1834)
1 parent c5be551 commit fc4e2a2

File tree

1 file changed

+49
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)