Skip to content

add SMART line

add SMART line #41

Workflow file for this run

# references:
# * understanding github actions: https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions
# * example sphinx publishing action: https://github.com/coderefinery/sphinx-lesson/blob/master/.github/workflows/sphinx.yml
name: sphinx
on: [push]
env:
DEFAULT_BRANCH: mtc_parameters
#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:
name: Build and gh-pages
runs-on: ubuntu-latest
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('dev-requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
# https://github.com/marketplace/actions/checkout
# Git clone network_wrangler
- name: Git clone network_wrangler
uses: actions/checkout@v3
with:
# Repository name with owner. For example, actions/checkout
repository: 'BayAreaMetro/network_wrangler'
# The branch, tag or SHA to checkout.
ref: 'generic_agency'
# Relative path under $GITHUB_WORKSPACE to place the repository
path: 'network_wrangler_clone'
# https://docs.github.com/en/actions/guides/building-and-testing-python#installing-dependencies
# ^-- This gives info on installing dependencies with pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
# this should be local from the Git clone action above
ls -l network_wrangler_clone
pip install ./network_wrangler_clone
- 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
# Build
- uses: ammaraskar/sphinx-problem-matcher@master
- name: Build Sphinx docs
run: |
cd docs
make dirhtml
# This fixes broken copy button icons, as explained in
# https://github.com/coderefinery/sphinx-lesson/issues/50
# https://github.com/executablebooks/sphinx-copybutton/issues/110
# This can be removed once these PRs are accepted (but the
# fixes also need to propagate to other themes):
# https://github.com/sphinx-doc/sphinx/pull/8524
# https://github.com/readthedocs/sphinx_rtd_theme/pull/1025
sed -i 's/url_root="#"/url_root=""/' _build/dirhtml/index.html || true
# The following supports building all branches and combining on
# gh-pages
# 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/branch/
# If a push and default branch, copy build to _gh-pages/ as the "main"
# deployment.
- name: Copy new build (default branch)
if: |
contains(github.event_name, 'push') &&
contains(github.ref, env.DEFAULT_BRANCH)
run: |
set -x
# Delete everything under _gh-pages/ that is from the
# primary branch deployment. Excludes the other branches
# _gh-pages/branch-* paths, and not including
# _gh-pages itself.
find _gh-pages/ -mindepth 1 ! -path '_gh-pages/branch*' -delete
rsync -a docs/_build/dirhtml/ _gh-pages/
# If a push and not on default branch, then copy the build to
# _gh-pages/branch/$brname (transforming '/' into '--')
- name: Copy new build (branch)
if: |
contains(github.event_name, 'push') &&
!contains(github.ref, env.DEFAULT_BRANCH)
run: |
set -x
#brname=$(git rev-parse --abbrev-ref HEAD)
brname="${{github.ref}}"
echo "brname:" ${brname}}
brname="${brname##refs/heads/}"
echo "brname:" ${brname}}
brdir=${brname//\//--} # replace '/' with '--'
echo "brdir:" ${brdir}}
rm -rf _gh-pages/branch/${brdir}
rsync -a docs/_build/dirhtml/ _gh-pages/branch/${brdir}
# Go through each branch in _gh-pages/branch/, if it's not a
# ref, then delete it.
- name: Delete old feature branches
if: ${{ github.event_name == 'push' }}
run: |
set -x
for brdir in `ls _gh-pages/branch/` ; do
brname=${brdir//--/\/} # replace '--' with '/'
if ! git show-ref remotes/origin/$brname ; then
echo "Removing $brdir"
rm -r _gh-pages/branch/$brdir/
fi
done
# 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