|
10 | 10 | - 'tutorials/**/*.ipynb' |
11 | 11 |
|
12 | 12 | jobs: |
| 13 | + # run on push |
| 14 | + export_tutorials_on_push: |
| 15 | + if: ${{ github.event_name == 'push' }} |
13 | 16 | export_tutorials: |
14 | 17 | permissions: write-all |
15 | 18 | runs-on: ubuntu-latest |
|
41 | 44 | git config user.name "github-actions[bot]" |
42 | 45 | git config user.email 41898282+github-actions[bot]@users.noreply.github.com |
43 | 46 |
|
| 47 | + - name: Run formatter |
| 48 | + run: black tutorials/ |
| 49 | + |
44 | 50 | - name: Export tutorials to .py and .html |
45 | 51 | run: | |
46 | 52 | set -x |
|
56 | 62 | done |
57 | 63 | set +x |
58 | 64 | |
| 65 | + - uses: benjlevesque/[email protected] |
| 66 | + id: short-sha |
| 67 | + |
| 68 | + - name: Remove unwanted files |
| 69 | + run: | |
| 70 | + rm -rf build/ tutorials/tutorial4/data/ |
| 71 | +
|
| 72 | + - name: Create Pull Request |
| 73 | + uses: peter-evans/[email protected] |
| 74 | + with: |
| 75 | + labels: maintenance |
| 76 | + title: Export tutorial changed in ${{ steps.short-sha.outputs.sha }} |
| 77 | + branch: export-tutorial-${{ steps.short-sha.outputs.sha }} |
| 78 | + base: ${{ github.head_ref }} |
| 79 | + commit-message: export tutorials changed in ${{ steps.short-sha.outputs.sha }} |
| 80 | + delete-branch: true |
| 81 | + |
| 82 | + # run on workflow_dispatch |
| 83 | + export_tutorials_workflow_dispatch: |
| 84 | + if: ${{ github.event_name == 'workflow_dispatch' }} |
| 85 | + permissions: write-all |
| 86 | + runs-on: ubuntu-latest |
| 87 | + env: |
| 88 | + TUTORIAL_TIMEOUT: 1200s |
| 89 | + steps: |
| 90 | + - uses: actions/checkout@v4 |
| 91 | + |
| 92 | + - name: Set up Python |
| 93 | + uses: actions/setup-python@v5 |
| 94 | + with: |
| 95 | + python-version: 3.8 |
| 96 | + |
| 97 | + - name: Install dependencies |
| 98 | + run: | |
| 99 | + python3 -m pip install --upgrade pip .[tutorial] black[jupyter] |
| 100 | +
|
| 101 | + - name: Setup FFmpeg |
| 102 | + uses: FedericoCarboni/setup-ffmpeg@v2 |
| 103 | + |
| 104 | + - name: Configure git |
| 105 | + run: | |
| 106 | + git config user.name "github-actions[bot]" |
| 107 | + git config user.email 41898282+github-actions[bot]@users.noreply.github.com |
| 108 | +
|
59 | 109 | - name: Run formatter |
60 | 110 | run: black tutorials/ |
61 | 111 |
|
| 112 | + - name: Export all tutorials to .py and .html |
| 113 | + run: | |
| 114 | + set -x |
| 115 | + # Find all .ipynb files in the tutorials directory |
| 116 | + for file in $(find tutorials -type f -name "*.ipynb"); do |
| 117 | + filename=$(basename $file) |
| 118 | + pyfilename="${filename%.ipynb}.py" |
| 119 | + timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert $file --to python --output $pyfilename --output-dir=$(dirname $file) |
| 120 | + htmlfilename="${filename%.ipynb}.html" |
| 121 | + htmldir="docs/source"/$(dirname $file) |
| 122 | + timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --execute $file --to html --output $htmlfilename --output-dir=$htmldir |
| 123 | + done |
| 124 | + set +x |
| 125 | +
|
62 | 126 | - uses: benjlevesque/[email protected] |
63 | 127 | id: short-sha |
64 | 128 |
|
|
0 commit comments