@@ -12,12 +12,13 @@ jobs:
1212 runs-on : ubuntu-latest
1313
1414 steps :
15- - name : Checkout Repo
15+ - name : Checkout Repository
1616 uses : actions/checkout@v4
1717 with :
1818 fetch-depth : 0
1919
20- - name : Get Changed Markdown Files (PR only)
20+ # === PR MODE ===
21+ - name : Get Changed Markdown Files (PR)
2122 id : changed-files
2223 if : github.event_name == 'pull_request'
2324 run : |
@@ -27,41 +28,41 @@ jobs:
2728 echo "$files" >> $GITHUB_OUTPUT
2829 echo "EOF" >> $GITHUB_OUTPUT
2930
30- - name : Run Initial Lychee Check (PR)
31+ - name : Run Lychee on Changed Markdown Files (PR)
3132 if : github.event_name == 'pull_request' && steps.changed-files.outputs.md_files != ''
3233 uses :
lycheeverse/[email protected] 3334 with :
3435 args : >
3536 --verbose --no-progress --exclude-mail --exclude ^https?://
36- --output lychee/initial .out
37+ --output lychee/pr .out
3738 ${{ steps.changed-files.outputs.md_files }}
3839 env :
3940 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4041
41- - name : Extract Markdown Files with Broken Links
42+ - name : Extract Affected Markdown Files (PR)
4243 if : github.event_name == 'pull_request'
43- id : affected-md
44+ id : affected-pr
4445 run : |
4546 mkdir -p sanitized_md
46- # Extract only .md file paths from the lychee output
47- affected=$(grep -E 'file://.*\.md' lychee/initial.out | cut -d' ' -f1 | sed 's|file://||' | sort -u)
47+ affected=$(grep -Eo 'file://[^ ]+\.md' lychee/pr.out | sed 's|file://||' | sort -u)
4848 echo "$affected"
4949 echo "affected_files<<EOF" >> $GITHUB_OUTPUT
5050 echo "$affected" >> $GITHUB_OUTPUT
5151 echo "EOF" >> $GITHUB_OUTPUT
5252
53- - name : Strip HTML Comments from Affected Markdown Files Only
54- if : steps.affected-md .outputs.affected_files != ''
53+ - name : Strip HTML Comments from Affected Files (PR)
54+ if : steps.affected-pr .outputs.affected_files != ''
5555 run : |
56- for file in ${{ steps.affected-md.outputs.affected_files }}; do
57- target="sanitized_md/$file"
58- mkdir -p "$(dirname "$target")"
59- # Copy the file and strip only comments
60- perl -0777 -pe 's/<!--.*?-->//gs' "$file" > "$target"
56+ echo "${{ steps.affected-pr.outputs.affected_files }}" | while read file; do
57+ if [ -f "$file" ]; then
58+ target="sanitized_md/$file"
59+ mkdir -p "$(dirname "$target")"
60+ perl -0777 -pe 's/<!--.*?-->//gs' "$file" > "$target"
61+ fi
6162 done
6263
63- - name : Rerun Lychee on Cleaned Files
64- if : steps.affected-md .outputs.affected_files != ''
64+ - name : Re-check Sanitized Affected Files (PR)
65+ if : steps.affected-pr .outputs.affected_files != ''
6566 uses :
lycheeverse/[email protected] 6667 with :
6768 args : >
@@ -70,20 +71,47 @@ jobs:
7071 env :
7172 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7273
73- - name : Full Repo Scan (Manual)
74+ # === MANUAL MODE ===
75+ - name : Run Lychee on Entire Repo (Manual)
76+ if : github.event_name == 'workflow_dispatch'
77+ uses :
lycheeverse/[email protected] 78+ with :
79+ args : >
80+ --verbose --no-progress --exclude-mail --exclude ^https?://
81+ --output lychee/manual.out
82+ '**/*.md'
83+ env :
84+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
85+
86+ - name : Extract Affected Markdown Files (Manual)
7487 if : github.event_name == 'workflow_dispatch'
88+ id : affected-manual
7589 run : |
7690 mkdir -p sanitized_md
77- rsync -av --exclude '.git' --exclude 'node_modules' ./ sanitized_md/
78- find sanitized_md -name "*.md" -exec perl -0777 -i -pe 's/<!--.*?-->//gs' {} +
91+ affected=$(grep -Eo 'file://[^ ]+\.md' lychee/manual.out | sed 's|file://||' | sort -u)
92+ echo "$affected"
93+ echo "affected_files<<EOF" >> $GITHUB_OUTPUT
94+ echo "$affected" >> $GITHUB_OUTPUT
95+ echo "EOF" >> $GITHUB_OUTPUT
7996
80- - name : Run Lychee on Entire Repo (Manual)
81- if : github.event_name == 'workflow_dispatch'
97+ - name : Strip HTML Comments from Affected Files (Manual)
98+ if : steps.affected-manual.outputs.affected_files != ''
99+ run : |
100+ echo "${{ steps.affected-manual.outputs.affected_files }}" | while read file; do
101+ if [ -f "$file" ]; then
102+ target="sanitized_md/$file"
103+ mkdir -p "$(dirname "$target")"
104+ perl -0777 -pe 's/<!--.*?-->//gs' "$file" > "$target"
105+ fi
106+ done
107+
108+ - name : Re-check Sanitized Affected Files (Manual)
109+ if : steps.affected-manual.outputs.affected_files != ''
82110 uses :
lycheeverse/[email protected] 83111 with :
84112 args : >
85113 --verbose --no-progress --exclude-mail --exclude ^https?://
86114 sanitized_md/**/*.md
87- output : lychee/full .out
115+ output : lychee/manual-cleaned .out
88116 env :
89117 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments