Skip to content

Deploy to GitHub Pages #709

Deploy to GitHub Pages

Deploy to GitHub Pages #709

Workflow file for this run

name: Deploy to GitHub Pages
on:
push:
branches: ["main", "master"]
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
env:
CACHE_NUMBER: 0
jobs:
deploy:
strategy:
matrix:
include:
- os: ubuntu-latest
label: linux-64
prefix: /usr/share/miniconda3/envs/my-env
defaults:
run:
shell: bash -l {0}
name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Create env file
shell: python
run: |
from configparser import ConfigParser
import subprocess
config = ConfigParser(delimiters=["="])
config.read("settings.ini")
cfg = config["DEFAULT"]
requirements = cfg.get("requirements", "").split()
with open("environment.yml", "w") as f:
f.write("name: my-env\n")
f.write("channels:\n - conda-forge\n")
f.write("dependencies:\n")
f.writelines([f" - {r}\n" for r in requirements])
- run: cat environment.yml
- name: Install conda env from environment.yml
# You may pin to the exact commit or the version.
# uses: mamba-org/provision-with-micromamba@e2b397b12d0a38069451664382b769c9456e3d6d
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: 'latest'
environment-file: environment.yml
init-shell: bash
cache-downloads: true
cache-environment: true
post-cleanup: 'none'
- name: Install package
run: |
pip install -e ".[dev]"
pip install planets
- name: Install tools and create docs
run: |
wget -nv https://www.quarto.org/download/latest/quarto-linux-amd64.deb
sudo dpkg -i quarto*.deb
echo "installed quarto"
pip install -Uq git+https://github.com/fastai/fastcore.git
pip install -Uq git+https://github.com/fastai/execnb.git
pip install -Uq git+https://github.com/fastai/nbdev.git
nbdev_docs
# - name: Install ghapi
# # this needs to be in the default shell so that below's default Python shell can activate GH pages
# shell: bash
# run: |
# pip install -Uq git+https://github.com/fastai/ghapi.git # you need this for enabling pages
# pip install -Uq git+https://github.com/fastai/nbdev.git
# - name: Enable GitHub Pages
# shell: python
# run: |
# import ghapi.core,nbdev.config,sys
# msg="Please enable GitHub Pages to publish from the root of the `gh-pages` branch per these instructions - https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-from-a-branch"
# try:
# api = ghapi.core.GhApi(owner=nbdev.config.get_config().user, repo=nbdev.config.get_config().repo, token="${{github.token}}")
# api.enable_pages(branch='gh-pages')
# except Exception as e:
# print(f'::error title="Could not enable GitHub Pages Automatically":: {msg}\n{e}')
# sys.exit(1)
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ github.token }}
force_orphan: true
publish_dir: ./_docs
# The following lines assign commit authorship to the official GH-Actions bot for deploys to `gh-pages` branch.
# You can swap them out with your own user credentials.
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com