-
Notifications
You must be signed in to change notification settings - Fork 1
101 lines (88 loc) · 3.7 KB
/
publish-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
name: publish-book
on:
workflow_dispatch:
env:
NB_KERNEL: python
ORG: neuromatch
NMA_REPO: nasa-open-science
NMA_MAIN_BRANCH: main
PREREQ_REPO: precourse
PREREQ_INTRO: ComputationalNeuroscience
# This job installs dependencies, build the book, and pushes it to `gh-pages`
jobs:
build-and-deploy-book:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Get commit message
run: |
readonly local msg=$(git log -1 --pretty=format:"%s")
echo "COMMIT_MESSAGE=$msg" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install CI tools
run: |
BRANCH=`python -c 'import os, re; m = re.search(r"nmaci:([\w-]+)", os.environ["COMMIT_MESSAGE"]); print("main" if m is None else m.group(1))'`
# NOTE: might enventually change this back if we integrate changes
wget https://github.com/$ORG/nmaci/archive/refs/heads/$BRANCH.tar.gz
tar -xzf $BRANCH.tar.gz
pip install --upgrade pip
pip install -r nmaci-$BRANCH/requirements.txt
mv nmaci-$BRANCH/scripts/ ci/
rm -r nmaci-$BRANCH
rm -r $BRANCH.tar.gz
echo ci/ >> .gitignore
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install jupyter-book==0.14.0 ghp-import
pip install jupyter_client==7.3.5 # downgrade jupyter-client to fix hangs
- name: Install XKCD fonts
if: "!contains(env.COMMIT_MESSAGE, 'skip ci')"
run: |
sudo apt-get update -yq
wget http://archive.ubuntu.com/ubuntu/pool/universe/f/fonts-humor-sans/fonts-humor-sans_1.0-4_all.deb
sudo dpkg -i --force-all fonts-humor-sans_1.0-4_all.deb <<< 'yes'
sudo apt install -fy
rm -f $HOME/.matplotlib/fontList.cache
# - name: Copy tutorials from precourse repo
# if: "!contains(env.COMMIT_MESSAGE, 'skip precourse')"
# run: |
# BRANCH=`python -c 'import os, re; m = re.search(r"precourse:([\w-]+)", os.environ["COMMIT_MESSAGE"]); print("main" if m is None else m.group(1))'`
# wget https://github.com/$ORG/$PREREQ_REPO/archive/refs/heads/$BRANCH.tar.gz
# tar -xzf $BRANCH.tar.gz
# mv precourse-$BRANCH/tutorials/W0D* tutorials/
# cat precourse-main/tutorials/materials.yml tutorials/materials.yml > out.yml
# mv out.yml tutorials/materials.yml
# mv precourse-$BRANCH/prereqs .
# rm -r precourse-$BRANCH
# rm -r $BRANCH.tar.gz
- name: Build student book
run: |
python ci/generate_book.py student
# convert _toc to new format
jupyter-book toc migrate /home/runner/work/nasa-open-science/nasa-open-science/book/_toc.yml -o /home/runner/work/nasa-open-science/nasa-open-science/book/_toc.yml
ln -s ../tutorials book/tutorials
ln -s ../projects book/projects
# ln -s ../prereqs book/prereqs
jupyter-book build book
python ci/parse_html_for_errors.py student
- name: Commit book
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
ghp-import -n -c "openscience.neuromatch.io" -m "Update course book" book/_build/html
git checkout -f gh-pages
- name: Publish to gh-pages
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
force: true