Skip to content

Commit 17aae47

Browse files
add workflow for checking broken links in Markdown files
1 parent bac0fff commit 17aae47

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
actions: read
12+
13+
jobs:
14+
markdown-link-check:
15+
name: Check Markdown Broken Links
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout Repo
20+
uses: actions/checkout@v6
21+
with:
22+
fetch-depth: 0
23+
24+
# For PR : Get only changed markdown files
25+
- name: Get changed markdown files (PR only)
26+
id: changed-markdown-files
27+
if: github.event_name == 'pull_request'
28+
uses: tj-actions/changed-files@e0021407031f5be11a464abee9a0776171c79891 # v46
29+
with:
30+
files: |
31+
**/*.md
32+
33+
34+
# For PR: Check broken links only in changed files
35+
- name: Check Broken Links in Changed Markdown Files
36+
id: lychee-check-pr
37+
if: github.event_name == 'pull_request' && steps.changed-markdown-files.outputs.any_changed == 'true'
38+
uses: lycheeverse/lychee-action@v2.7.0
39+
with:
40+
args: >
41+
--verbose --no-progress --exclude ^https?://
42+
${{ steps.changed-markdown-files.outputs.all_changed_files }}
43+
failIfEmpty: false
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
47+
# For manual trigger: Check all markdown files in repo
48+
- name: Check Broken Links in All Markdown Files in Entire Repo (Manual Trigger)
49+
id: lychee-check-manual
50+
if: github.event_name == 'workflow_dispatch'
51+
uses: lycheeverse/lychee-action@v2.7.0
52+
with:
53+
args: >
54+
--verbose --no-progress --exclude ^https?://
55+
'**/*.md'
56+
failIfEmpty: false
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)