1+ name : " Export tutorials"
2+
3+ on :
4+ push :
5+ branches :
6+ - " **" # Run on push on all branches
7+ paths :
8+ - ' tutorials/**/*.ipynb'
9+
10+ jobs :
11+ export_tutorials :
12+ permissions : write-all
13+ runs-on : ubuntu-latest
14+ env :
15+ TUTORIAL_TIMEOUT : 1200s
16+ steps :
17+ - uses : actions/checkout@v4
18+
19+ - name : Set up Python
20+ uses : actions/setup-python@v5
21+ with :
22+ python-version : 3.8
23+
24+ - name : Install dependencies
25+ run : |
26+ # Dependencies for tutorials
27+ python3 -m pip install --upgrade pip .[tutorial] black[jupyter]
28+
29+ - name : Setup FFmpeg
30+ uses : FedericoCarboni/setup-ffmpeg@v2
31+
32+ - id : files
33+ uses : jitterbit/get-changed-files@v1
34+ with :
35+ token : ${{ secrets.GITHUB_TOKEN }}
36+ format : space-delimited
37+
38+ - name : Configure git
39+ run : |
40+ git config user.name "github-actions[bot]"
41+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
42+
43+ - name : Export tutorials to .py and .html
44+ run : |
45+ set -x
46+ for file in ${{ steps.files.outputs.all }}; do
47+ if [[ $file == *.ipynb ]]; then
48+ filename=$(basename $file)
49+
50+ pyfilename=$(echo ${filename%?????})py
51+ timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to python --output $pyfilename --output-dir=$(dirname $file)
52+
53+ htmlfilename=$(echo ${filename%?????} | sed -e 's/-//g')html
54+ htmldir="docs/source"/$(echo ${file%?????} | sed -e 's/-//g')html
55+ timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to html --output $htmlfilename --output-dir=$htmldir
56+ fi
57+ done
58+ set +x
59+
60+ - name : Run formatter
61+ run : black tutorials/
62+
63+ -
uses :
benjlevesque/[email protected] 64+ id : short-sha
65+
66+ - name : Remove unwanted files
67+ run : |
68+ rm -rf build/
69+
70+ - name : Create Pull Request
71+ uses :
peter-evans/[email protected] 72+ with :
73+ labels : maintenance
74+ title : Export tutorial changed in ${{ steps.short-sha.outputs.sha }}
75+ branch : export-tutorial-${{ steps.short-sha.outputs.sha }}
76+ commit-message : export tutorials changed in ${{ steps.short-sha.outputs.sha }}
77+ delete-branch : true
0 commit comments