Skip to content

publish-book

publish-book #154

Workflow file for this run

name: publish-book
on:
workflow_dispatch:
env:
NB_KERNEL: python
NMA_REPO: climate-course-content
NMA_MAIN_BRANCH: main
PREREQ_INTRO: ClimateScience
ORG: neuromatch
# This job installs dependencies, build the book, and pushes it to `gh-pages`
jobs:
build-books-and-deploy:
runs-on: climate_runner
# 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: Setup
uses: ./.github/actions/setup
with:
force_env_update: 'false'
- name: Cache Jupyter Build Artifacts
uses: actions/cache@v3
with:
path: |
./book/_build/html/
./.jupyter_cache
key: ${{ runner.os }}-jupyter-${{ hashFiles('**/*.ipynb') }}
restore-keys: |
${{ runner.os }}-jupyter-
- name: Build student book
run: |
# TODO: get this working with a general CI
# python ci/generate_book_climate.py student
python ci/generate_book.py student
jupyter-book toc migrate /home/runner/work/climate-course-content/climate-course-content/book/_toc.yml -o /home/runner/work/climate-course-content/climate-course-content/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
shell: bash -l {0}
# NOTE: we may be able to push striaght from here. ie skip the last flow
- name: Commit book
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
ghp-import -n -c "comptools.climatematch.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