Skip to content

Commit 5eaee6c

Browse files
committed
syntax
1 parent 9e5e677 commit 5eaee6c

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

.github/workflows/tutorial_exporter.yml

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ on:
1111

1212
jobs:
1313
# run on push
14-
if: ${{ github.event_name != 'workflow_dispatch' }}
15-
export_tutorials_workflow_dispatch:
14+
export_tutorials_push:
15+
if: ${{ github.event_name != 'workflow_dispatch' }}
1616
permissions: write-all
1717
runs-on: ubuntu-latest
1818
env:
@@ -27,8 +27,8 @@ jobs:
2727

2828
- name: Install dependencies
2929
run: |
30-
# Dependencies for tutorials
3130
python3 -m pip install --upgrade pip .[tutorial] black[jupyter]
31+
3232
- name: Setup FFmpeg
3333
uses: FedericoCarboni/setup-ffmpeg@v2
3434

@@ -49,15 +49,15 @@ jobs:
4949
for file in ${{ steps.files.outputs.all }}; do
5050
if [[ $file == *.ipynb ]]; then
5151
filename=$(basename $file)
52-
pyfilename=$(echo ${filename%?????})py
52+
pyfilename="${filename%.ipynb}.py"
5353
timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert $file --to python --output $pyfilename --output-dir=$(dirname $file)
54-
htmlfilename=$(echo ${filename%?????} | sed -e 's/-//g')html
55-
htmldir="docs/source"/$(echo ${file%??????????????} | sed -e 's/-//g')
54+
htmlfilename="${filename%.ipynb}"html
55+
htmldir="docs/source"/$(dirname $file)
5656
timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to html --output $htmlfilename --output-dir=$htmldir
5757
fi
5858
done
5959
set +x
60-
60+
6161
- name: Run formatter
6262
run: black tutorials/
6363

@@ -77,9 +77,10 @@ jobs:
7777
base: ${{ github.head_ref }}
7878
commit-message: export tutorials changed in ${{ steps.short-sha.outputs.sha }}
7979
delete-branch: true
80+
8081
# run on workflow_dispatch
81-
if: ${{ github.event_name = 'workflow_dispatch' }}
8282
export_tutorials_workflow_dispatch:
83+
if: ${{ github.event_name == 'workflow_dispatch' }}
8384
permissions: write-all
8485
runs-on: ubuntu-latest
8586
env:
@@ -94,19 +95,11 @@ jobs:
9495

9596
- name: Install dependencies
9697
run: |
97-
# Dependencies for tutorials
9898
python3 -m pip install --upgrade pip .[tutorial] black[jupyter]
9999
100100
- name: Setup FFmpeg
101101
uses: FedericoCarboni/setup-ffmpeg@v2
102102

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-
110103
- name: Configure git
111104
run: |
112105
git config user.name "github-actions[bot]"
@@ -115,18 +108,17 @@ jobs:
115108
- name: Export tutorials to .py and .html
116109
run: |
117110
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
111+
# Find all .ipynb files in the tutorials directory
112+
for file in $(find tutorials -type f -name "*.ipynb"); do
113+
filename=$(basename $file)
114+
pyfilename="${filename%.ipynb}.py"
115+
timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert $file --to python --output $pyfilename --output-dir=$(dirname $file)
116+
htmlfilename="${filename%.ipynb}.html"
117+
htmldir="docs/source"/$(dirname $file)
118+
timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to html --output $htmlfilename --output-dir=$htmldir
127119
done
128120
set +x
129-
121+
130122
- name: Run formatter
131123
run: black tutorials/
132124

@@ -145,4 +137,4 @@ jobs:
145137
branch: export-tutorial-${{ steps.short-sha.outputs.sha }}
146138
base: ${{ github.head_ref }}
147139
commit-message: export tutorials changed in ${{ steps.short-sha.outputs.sha }}
148-
delete-branch: true
140+
delete-branch: true

0 commit comments

Comments
 (0)