-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (58 loc) · 1.76 KB
/
convert-notebook.yml
File metadata and controls
70 lines (58 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Convert Jupyter Notebook to HTML and Deploy to GitHub Pages
on:
push:
paths:
- '**.ipynb'
jobs:
convert:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
- name: Install Git LFS
run: git lfs install
- name: Pull LFS files (redundant but safe)
run: git lfs pull
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install --upgrade pip
pip install notebook==7.0.6 pandas matplotlib numpy plotly scikit-learn
- name: Validate notebooks
run: |
set -e
FAILED=0
for notebook in $(find . -name "*.ipynb" 2>/dev/null); do
if [ -f "$notebook" ]; then
python -c "import json; json.load(open('$notebook'))" || { echo "Invalid JSON in $notebook"; FAILED=1; }
fi
done
exit $FAILED
- name: Clean output directory
run: rm -rf converted_html && mkdir -p converted_html
- name: Convert all notebooks to HTML
run: |
set -e
for notebook in $(find . -name "*.ipynb" 2>/dev/null); do
if [ -f "$notebook" ]; then
jupyter nbconvert --to html "$notebook" --output-dir=converted_html
fi
done
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./converted_html
force_orphan: true