Skip to content

update

update #295

# From: https://github.com/rkdarst/sphinx-actions-test/blob/master/.github/workflows/sphinx-build.yml
name: sphinx_docs
on:
push:
branches:
- main
pull_request:
env:
DEFAULT_BRANCH: "master"
#SPHINXOPTS: "-W --keep-going -T"
# ^-- If these SPHINXOPTS are enabled, then be strict about the builds and fail on any warnings
jobs:
build-and-deploy_docs:
name: Docs and Presentations
runs-on: ubuntu-latest
env:
ON_CI: True
NEEDS_AZURE_TOKEN: ${{ secrets.AZURE_TOKEN }}
steps:
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v2
with:
fetch-depth: 0
lfs: true
# https://github.com/marketplace/actions/setup-python
# ^-- This gives info on matrix testing.
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.8
# https://docs.github.com/en/actions/guides/building-and-testing-python#caching-dependencies
# ^-- How to set up caching for pip on Ubuntu
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
# https://docs.github.com/en/actions/guides/building-and-testing-python#installing-dependencies
# ^-- This gives info on installing dependencies with pip
- name: Install project
run: pip install .
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements.txt
pip install -r presentations/requirements.txt
- name: Debugging information
run: |
echo "github.ref:" ${{github.ref}}
echo "github.event_name:" ${{github.event_name}}
echo "github.head_ref:" ${{github.head_ref}}
echo "github.base_ref:" ${{github.base_ref}}
set -x
git rev-parse --abbrev-ref HEAD
git branch
git branch -a
git remote -v
python -V
pip list --not-required
pip list
echo "ON_CI = $ON_CI"
# Build
- uses: ammaraskar/sphinx-problem-matcher@master
- name: Build Sphinx docs
run: |
cd docs
make html
# Build
- uses: ammaraskar/sphinx-problem-matcher@master
- name: Build Sphinx presentations
run: |
cd presentations
make revealjs
# Clone and set up the old gh-pages branch
- name: Clone old gh-pages
if: ${{ github.event_name == 'push' }}
run: |
set -x
git fetch
( git branch gh-pages remotes/origin/gh-pages && git clone . --branch=gh-pages _gh-pages/ ) || mkdir _gh-pages
rm -rf _gh-pages/.git/
mkdir -p _gh-pages/
mkdir -p _gh-pages/presentations/
# If a push and default branch, copy build to _gh-pages/ as the "main"
# deployment.
- name: Copy docs build
if: |
contains(github.event_name, 'push')
run: |
set -x
rsync -a docs/_build/html/ _gh-pages/
- name: Copy presentation build
if: |
contains(github.event_name, 'push')
run: |
set -x
rsync -a presentations/_build/revealjs/ _gh-pages/presentations/
# Add the .nojekyll file
- name: nojekyll
if: ${{ github.event_name == 'push' }}
run: |
touch _gh-pages/.nojekyll
# Deploy
# https://github.com/peaceiris/actions-gh-pages
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' }}
#if: ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/$defaultBranch' }}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _gh-pages/
force_orphan: true