44 workflow_dispatch :
55 push :
66 branches :
7- - " dev"
8- - " master"
9- paths :
10- - ' tutorials/**/*.ipynb'
7+ - master
8+ - dev
119
1210jobs :
1311 export_tutorials :
@@ -21,20 +19,32 @@ jobs:
2119 - name : Set up Python
2220 uses : actions/setup-python@v5
2321 with :
24- python-version : 3.8
22+ python-version : 3.8 # using the minimum compatible python version
2523
2624 - name : Install dependencies
2725 run : |
2826 # Dependencies for tutorials
2927 python3 -m pip install --upgrade pip .[tutorial] black[jupyter]
28+
3029 - name : Setup FFmpeg
3130 uses : FedericoCarboni/setup-ffmpeg@v2
3231
33- - id : files
34- uses : jitterbit/get-changed-files@v1
35- with :
36- token : ${{ secrets.GITHUB_TOKEN }}
37- format : space-delimited
32+ - name : Determine files to process
33+ id : files
34+ run : |
35+ BASE_BRANCH=${{ github.event.ref == 'refs/heads/dev' && 'dev' || 'master' }}
36+ git fetch origin $BASE_BRANCH
37+ MERGE_BASE=$(git merge-base HEAD origin/$BASE_BRANCH)
38+ CHANGED_FILES=$(git diff --name-only $MERGE_BASE HEAD | grep 'tutorials/.*\.ipynb' || true)
39+
40+ if [ -n "$CHANGED_FILES" ]; then
41+ echo "all=$CHANGED_FILES" >> $GITHUB_ENV
42+ elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
43+ echo "all=tutorials/**/*.ipynb" >> $GITHUB_ENV
44+ else
45+ echo "No tutorials changed, skipping."
46+ exit 0
47+ fi
3848
3949 - name : Configure git
4050 run : |
@@ -44,18 +54,16 @@ jobs:
4454 - name : Export tutorials to .py and .html
4555 run : |
4656 set -x
47- for file in ${{ steps.files.outputs.all }}; do
48- if [[ $file == *.ipynb ]]; then
49- filename=$(basename $file)
50- pyfilename=$(echo ${filename%?????})py
51- timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert $file --to python --output $pyfilename --output-dir=$(dirname $file)
52- htmlfilename=$(echo ${filename%?????} | sed -e 's/-//g')html
53- htmldir="docs/source"/$(echo ${file%??????????????} | sed -e 's/-//g')
54- timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to html --output $htmlfilename --output-dir=$htmldir
55- fi
57+ for file in $all; do
58+ filename=$(basename $file)
59+ pyfilename=$(echo ${filename%?????})py
60+ timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert $file --to python --output $pyfilename --output-dir=$(dirname $file)
61+ htmlfilename=$(echo ${filename%?????} | sed -e 's/-//g')html
62+ htmldir="docs/source"/$(echo ${file%??????????????} | sed -e 's/-//g')
63+ timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to html --output $htmlfilename --output-dir=$htmldir
5664 done
5765 set +x
58-
66+
5967 - name : Run formatter
6068 run : black tutorials/
6169
0 commit comments