Skip to content

Commit

Permalink
split test and deploy workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasBeuzen committed Aug 17, 2020
1 parent a2243e2 commit b97ab98
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 39 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: tests

on:
# Trigger the deploy on push to master branch
push:
branches:
- master

jobs:
# This job deploys the example book
deploy-example-book:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.8]
steps:
- uses: actions/checkout@v2
# Install CC
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install cookiecutter
# Use default CC
- name: Cookiecutter no GHA
run: |
cookiecutter . --no-input include_github_actions=no
# Install requirements.txt
- name: Install requirements
run: |
pip install -r my_book/requirements.txt
# Build the example book
- name: Build book
run: |
jupyter-book build my_book/my_book/
# Deploy html to gh-pages
- name: GitHub Pages action
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: my_book/my_book/_build/html
41 changes: 4 additions & 37 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
# This job tests that the CC works
Expand All @@ -31,40 +34,4 @@ jobs:
# Use the CC with no GitHub action file included
- name: Cookiecutter default
run: |
cookiecutter . --no-input --overwrite-if-exists
# This job deploys the example book
deploy-example-book:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.8]
steps:
- uses: actions/checkout@v2
# Install CC
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install cookiecutter
# Use default CC
- name: Cookiecutter no GHA
run: |
cookiecutter . --no-input include_github_actions=no
# Install requirements.txt
- name: Install requirements
run: |
pip install -r my_book/requirements.txt
# Build the example book
- name: Build book
run: |
jupyter-book build my_book/my_book/
# Deploy html to gh-pages
- name: GitHub Pages action
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: my_book/my_book/_build/html
cookiecutter . --no-input --overwrite-if-exists
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Cookiecutter Jupyter Book

![tests](https://github.com/UBC-MDS/cookiecutter-jupyter-book/workflows/tests/badge.svg)
[![maintenance](https://img.shields.io/badge/maintained-yes-success.svg)](https://github.com/UBC-MDS/cookiecutter-jupyter-book/graphs/commit-activity)
![deploy](https://github.com/UBC-MDS/cookiecutter-jupyter-book/workflows/deploy/badge.svg)
[![release](https://img.shields.io/github/release/UBC-MDS/cookiecutter-jupyter-book.svg)](https://github.com/UBC-MDS/cookiecutter-jupyter-book/releases)
[![python](https://img.shields.io/badge/python-3.7%2C%203.8-blue)]()
[![os](https://img.shields.io/badge/OS-Ubuntu%2C%20Mac%2C%20Windows-yellow)]()
Expand Down Expand Up @@ -105,7 +105,7 @@ $ jupyter-book build my_book/
$ git push -u origin master
```

4. The GitHub Actions workflow provided with the cookiecutter (`my_book/.github/workflows/deploy.yml`) will automatically deploy your book to the `gh-pages` branch of your repository once pushed. You may need to go to the `Settings` tab of your repository and under the **GitHub Pages** heading, choose the `gh-pages branch` from the **Source** drop-down list. For alternative methods of deploying your book online, see the See the [Jupyter Book documentation](https://jupyterbook.org/intro.html).
4. The GitHub Actions workflow provided with the cookiecutter (`my_book/.github/workflows/deploy.yml`) will automatically deploy your book to the `gh-pages` branch of your repository once pushed. It is typically available after a few minutes at `https://<user>.github.io/<myonlinebook>/`. You may need to go to the `Settings` tab of your repository and under the **GitHub Pages** heading, choose the `gh-pages branch` from the **Source** drop-down list. For alternative methods of deploying your book online, see the See the [Jupyter Book documentation](https://jupyterbook.org/intro.html).

> Note: by default, the GitHub Actions workflow file included with this cookiecutter builds the book with Ubuntu and Python 3.8. You can modify the OS/Python version for the build in the `.github/workflows/deploy.yml` file on lines 15 and 16 respectively.

Expand Down

0 comments on commit b97ab98

Please sign in to comment.