-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (56 loc) · 2.15 KB
/
run_notebooks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Run Notebooks and Save Outputs
on:
push:
branches:
- main # Trigger the action on the main branch
jobs:
run-notebooks:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Clear GitHub Action Caches
run: |
echo "Clearing caches..."
sudo rm -rf ~/.cache/pip
sudo rm -rf executed_notebooks
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install SCT
run: |
git clone --depth 1 https://github.com/spinalcordtoolbox/spinalcordtoolbox.git
yes | spinalcordtoolbox/install_sct
- name: Run Jupyter Notebooks
continue-on-error: true # Allow workflow to continue even if notebook execution fails
run: |
mkdir -p executed_notebooks
for notebook in $(find . -name "*.ipynb"); do
echo "Executing $notebook"
jupyter nbconvert --to notebook --execute --allow-errors --inplace \
--output executed_notebooks/$(basename $notebook) $notebook \
2>&1 | tee -a notebook_execution.log || echo "Execution failed for $notebook"
done
- name: List Executed Notebooks (Debug Step)
run: |
echo "Listing executed notebooks:"
ls -l executed_notebooks || echo "No notebooks found."
- name: Copy Executed Notebooks to Pages Directory
run: |
COMMIT_SHA=$(git rev-parse --short HEAD)
mkdir -p gh-pages/$COMMIT_SHA
cp executed_notebooks/*.ipynb gh-pages/$COMMIT_SHA/ || echo "No executed notebooks to copy."
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: gh-pages
publish_branch: gh-pages
- name: Success or Failure Message
if: failure()
run: echo "Notebooks executed with errors, but pushed to GitHub Pages."