Skip to content

Commit fc8ad33

Browse files
authored
Automatize Tutorials html, py files creation (#496)
* workflow to export tutorials ---------
1 parent da98d61 commit fc8ad33

File tree

51 files changed

+140525
-436
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

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

0 commit comments

Comments
 (0)