Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 94 additions & 9 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,119 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

with:
fetch-depth: 0

- name: Get changed files
id: changed-files
if: github.event_name == 'pull_request'
run: |
# Get list of changed files
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '\.(md|ipynb)$' || true)
echo "Changed files:"
echo "$CHANGED_FILES"

# Save changed files to output
if [ -z "$CHANGED_FILES" ]; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "files<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi

- name: Setup Python
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || steps.changed-files.outputs.has_changes == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Convert notebooks for link extraction

- name: Convert notebooks for link extraction (PR - changed files only)
if: github.event_name == 'pull_request' && steps.changed-files.outputs.has_changes == 'true'
run: |
pip install jupyter nbconvert
mkdir -p temp_md


# Convert only changed notebooks
echo "${{ steps.changed-files.outputs.files }}" | grep '\.ipynb$' | while read nb; do
if [ -f "$nb" ]; then
echo "Converting: $nb"
jupyter nbconvert --to markdown "$nb" \
--output-dir=temp_md \
--ExtractOutputPreprocessor.enabled=False
fi
done

- name: Convert notebooks for link extraction (scheduled/manual - all files)
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
run: |
pip install jupyter nbconvert
mkdir -p temp_md

for nb in $(find . -name "*.ipynb" -not -path "*/.*"); do
echo "Converting: $nb"
jupyter nbconvert --to markdown "$nb" \
--output-dir=temp_md \
--ExtractOutputPreprocessor.enabled=False
done

- name: Check Links with Lychee

- name: Prepare file list for link checking (PR)
if: github.event_name == 'pull_request' && steps.changed-files.outputs.has_changes == 'true'
id: file-list
run: |
FILES=""

# Add changed markdown files from skills directory
echo "${{ steps.changed-files.outputs.files }}" | grep '^skills/.*\.md$' | while read f; do
if [ -f "$f" ]; then
FILES="$FILES $f"
fi
done

# Add converted notebooks
if [ -d "temp_md" ]; then
FILES="$FILES temp_md/*.md"
fi

# Add README.md if changed
if echo "${{ steps.changed-files.outputs.files }}" | grep -q '^README\.md$'; then
FILES="$FILES README.md"
fi

# Remove leading/trailing whitespace
FILES=$(echo $FILES | xargs)

if [ -z "$FILES" ]; then
echo "file_args=" >> $GITHUB_OUTPUT
else
echo "file_args=$FILES" >> $GITHUB_OUTPUT
fi

- name: Check Links with Lychee (PR - changed files only)
if: github.event_name == 'pull_request' && steps.changed-files.outputs.has_changes == 'true'
id: lychee
uses: lycheeverse/lychee-action@v2
with:
args: |
--config lychee.toml
--config lychee.toml
--format markdown
--no-progress
${{ steps.file-list.outputs.file_args }}
output: lychee-report.md
fail: false

- name: Check Links with Lychee (scheduled/manual - all files)
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
id: lychee-full
uses: lycheeverse/lychee-action@v2
with:
args: |
--config lychee.toml
--format markdown
--no-progress
skills/**/*.md
temp_md/*.md
skills/**/*.md
temp_md/*.md
README.md
output: lychee-report.md
fail: false
Expand Down
Loading
Loading