-
Notifications
You must be signed in to change notification settings - Fork 5
129 lines (102 loc) · 3.04 KB
/
deploy-jupyter-book.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Deploy Jupyter Book
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-book:
runs-on: ubuntu-latest
container: atlasamglab/stats-base:root6.28.04
steps:
- uses: actions/checkout@v3
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --no-deps --require-hashes --requirement book/requirements.lock
- name: List installed Python packages
run: |
python -m pip list
- name: Set track_progress=False for notebooks
run: |
git config --global --add safe.directory /__w/pyhf-tutorial/pyhf-tutorial
git grep --name-only "track_progress=True" book | xargs sed --in-place 's/track_progress=True/track_progress=False/g'
- name: Build the book
run: |
jupyter-book build book/
- name: Upload jupyter book
uses: actions/upload-artifact@v3
with:
name: jupyterbook
path: 'book/_build/html/'
build-pyodide:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install pyodide
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade \
"jupyterlite[lab]" \
"jupytext>=1.14.0"
- name: List installed Python packages
run: |
python -m pip list
- name: Convert .py to notebook
run: |
jupytext --to notebook lite/jupyterlite.py
cp lite/*.ipynb book/
- name: Build the Pyodide output
run: |
jupyter lite --help
jupyter lite init
jupyter lite build --contents=book
jupyter lite check
- name: Upload Pyodide build
uses: actions/upload-artifact@v3
with:
name: jupyterlite
path: _output/
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: [build-book, build-pyodide]
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
steps:
- name: Setup Pages
uses: actions/configure-pages@v2
- uses: actions/download-artifact@v3
with:
name: jupyterbook
path: 'public'
- uses: actions/download-artifact@v3
with:
name: jupyterlite
path: 'public/live'
- name: Fix permissions
run: |
chmod -c -R +rX "public/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: 'public'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1