@@ -16,34 +16,119 @@ jobs:
1616 runs-on : ubuntu-latest
1717 steps :
1818 - uses : actions/checkout@v4
19-
19+ with :
20+ fetch-depth : 0
21+
22+ - name : Get changed files
23+ id : changed-files
24+ if : github.event_name == 'pull_request'
25+ run : |
26+ # Get list of changed files
27+ CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '\.(md|ipynb)$' || true)
28+ echo "Changed files:"
29+ echo "$CHANGED_FILES"
30+
31+ # Save changed files to output
32+ if [ -z "$CHANGED_FILES" ]; then
33+ echo "has_changes=false" >> $GITHUB_OUTPUT
34+ else
35+ echo "has_changes=true" >> $GITHUB_OUTPUT
36+ echo "files<<EOF" >> $GITHUB_OUTPUT
37+ echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
38+ echo "EOF" >> $GITHUB_OUTPUT
39+ fi
40+
2041 - name : Setup Python
42+ if : github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || steps.changed-files.outputs.has_changes == 'true'
2143 uses : actions/setup-python@v5
2244 with :
2345 python-version : ' 3.11'
24-
25- - name : Convert notebooks for link extraction
46+
47+ - name : Convert notebooks for link extraction (PR - changed files only)
48+ if : github.event_name == 'pull_request' && steps.changed-files.outputs.has_changes == 'true'
2649 run : |
2750 pip install jupyter nbconvert
2851 mkdir -p temp_md
29-
52+
53+ # Convert only changed notebooks
54+ echo "${{ steps.changed-files.outputs.files }}" | grep '\.ipynb$' | while read nb; do
55+ if [ -f "$nb" ]; then
56+ echo "Converting: $nb"
57+ jupyter nbconvert --to markdown "$nb" \
58+ --output-dir=temp_md \
59+ --ExtractOutputPreprocessor.enabled=False
60+ fi
61+ done
62+
63+ - name : Convert notebooks for link extraction (scheduled/manual - all files)
64+ if : github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
65+ run : |
66+ pip install jupyter nbconvert
67+ mkdir -p temp_md
68+
3069 for nb in $(find . -name "*.ipynb" -not -path "*/.*"); do
3170 echo "Converting: $nb"
3271 jupyter nbconvert --to markdown "$nb" \
3372 --output-dir=temp_md \
3473 --ExtractOutputPreprocessor.enabled=False
3574 done
36-
37- - name : Check Links with Lychee
75+
76+ - name : Prepare file list for link checking (PR)
77+ if : github.event_name == 'pull_request' && steps.changed-files.outputs.has_changes == 'true'
78+ id : file-list
79+ run : |
80+ FILES=""
81+
82+ # Add changed markdown files from skills directory
83+ echo "${{ steps.changed-files.outputs.files }}" | grep '^skills/.*\.md$' | while read f; do
84+ if [ -f "$f" ]; then
85+ FILES="$FILES $f"
86+ fi
87+ done
88+
89+ # Add converted notebooks
90+ if [ -d "temp_md" ]; then
91+ FILES="$FILES temp_md/*.md"
92+ fi
93+
94+ # Add README.md if changed
95+ if echo "${{ steps.changed-files.outputs.files }}" | grep -q '^README\.md$'; then
96+ FILES="$FILES README.md"
97+ fi
98+
99+ # Remove leading/trailing whitespace
100+ FILES=$(echo $FILES | xargs)
101+
102+ if [ -z "$FILES" ]; then
103+ echo "file_args=" >> $GITHUB_OUTPUT
104+ else
105+ echo "file_args=$FILES" >> $GITHUB_OUTPUT
106+ fi
107+
108+ - name : Check Links with Lychee (PR - changed files only)
109+ if : github.event_name == 'pull_request' && steps.changed-files.outputs.has_changes == 'true'
38110 id : lychee
39111 uses : lycheeverse/lychee-action@v2
40112 with :
41113 args : |
42- --config lychee.toml
114+ --config lychee.toml
115+ --format markdown
116+ --no-progress
117+ ${{ steps.file-list.outputs.file_args }}
118+ output : lychee-report.md
119+ fail : false
120+
121+ - name : Check Links with Lychee (scheduled/manual - all files)
122+ if : github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
123+ id : lychee-full
124+ uses : lycheeverse/lychee-action@v2
125+ with :
126+ args : |
127+ --config lychee.toml
43128 --format markdown
44129 --no-progress
45- skills/**/*.md
46- temp_md/*.md
130+ skills/**/*.md
131+ temp_md/*.md
47132 README.md
48133 output : lychee-report.md
49134 fail : false
0 commit comments