1010 - ' tutorials/**/*.ipynb'
1111
1212jobs :
13- export_tutorials :
13+ # run on push
14+ if : ${{ github.event_name != 'workflow_dispatch' }}
15+ export_tutorials_workflow_dispatch :
1416 permissions : write-all
1517 runs-on : ubuntu-latest
1618 env :
7577 base : ${{ github.head_ref }}
7678 commit-message : export tutorials changed in ${{ steps.short-sha.outputs.sha }}
7779 delete-branch : true
80+ # run on workflow_dispatch
81+ if : ${{ github.event_name = 'workflow_dispatch' }}
82+ export_tutorials_workflow_dispatch :
83+ permissions : write-all
84+ runs-on : ubuntu-latest
85+ env :
86+ TUTORIAL_TIMEOUT : 1200s
87+ steps :
88+ - uses : actions/checkout@v4
89+
90+ - name : Set up Python
91+ uses : actions/setup-python@v5
92+ with :
93+ python-version : 3.8
94+
95+ - name : Install dependencies
96+ run : |
97+ # Dependencies for tutorials
98+ python3 -m pip install --upgrade pip .[tutorial] black[jupyter]
99+
100+ - name : Setup FFmpeg
101+ uses : FedericoCarboni/setup-ffmpeg@v2
102+
103+ - name : Find all .ipynb files
104+ id : files
105+ run : |
106+ # Use `find` to locate all .ipynb files in the tutorials folder
107+ IPYNB_FILES=$(find tutorials -type f -name "*.ipynb")
108+ echo "all=$IPYNB_FILES" >> $GITHUB_ENV
109+
110+ - name : Configure git
111+ run : |
112+ git config user.name "github-actions[bot]"
113+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
114+
115+ - name : Export tutorials to .py and .html
116+ run : |
117+ set -x
118+ for file in ${{ env.all}}; do
119+ if [[ $file == *.ipynb ]]; then
120+ filename=$(basename $file)
121+ pyfilename=$(echo ${filename%?????})py
122+ timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert $file --to python --output $pyfilename --output-dir=$(dirname $file)
123+ htmlfilename=$(echo ${filename%?????} | sed -e 's/-//g')html
124+ htmldir="docs/source"/$(echo ${file%??????????????} | sed -e 's/-//g')
125+ timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to html --output $htmlfilename --output-dir=$htmldir
126+ fi
127+ done
128+ set +x
129+
130+ - name : Run formatter
131+ run : black tutorials/
132+
133+ -
uses :
benjlevesque/[email protected] 134+ id : short-sha
135+
136+ - name : Remove unwanted files
137+ run : |
138+ rm -rf build/ tutorials/tutorial4/data/
139+
140+ - name : Create Pull Request
141+ uses :
peter-evans/[email protected] 142+ with :
143+ labels : maintenance
144+ title : Export tutorial changed in ${{ steps.short-sha.outputs.sha }}
145+ branch : export-tutorial-${{ steps.short-sha.outputs.sha }}
146+ base : ${{ github.head_ref }}
147+ commit-message : export tutorials changed in ${{ steps.short-sha.outputs.sha }}
148+ delete-branch : true
0 commit comments