Skip to content

Merge pull request #294 from rochefort-lab/doc_min-sphinx #108

Merge pull request #294 from rochefort-lab/doc_min-sphinx

Merge pull request #294 from rochefort-lab/doc_min-sphinx #108

Workflow file for this run

# Docs workflow
#
# Deploys example notebooks to github pages.
name: gh-pages
on:
push:
branches: [main, master]
jobs:
notebooks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Determine default branch
run: |
DEFAULT_BRANCH=$(git remote show origin | awk '/HEAD branch/ {print $NF}')
echo "default_branch=$DEFAULT_BRANCH" >> $GITHUB_ENV
echo "default_branch_ref=refs/heads/$DEFAULT_BRANCH" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: ${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[plotting]
python -m pip install sima
- name: Build notebooks
run: |
cd examples
for file in *.ipynb; do
echo "Processing $file";
jupyter nbconvert --execute --to notebook --inplace "$file" \
&& jupyter nbconvert --to html "$file" \
|| echo "Error executing $file notebook";
if [ ! -f "${file%.*}.html" ]; then
jupyter nbconvert --to html "$file" \
|| echo "Error converting $file to HTML";
fi;
done
cd ..
- name: Add index.html redirect
run: |
mkdir public;
mv examples public/;
NEW_URL="https://fissa.readthedocs.io/";
FILE="public/index.html";
echo "<!DOCTYPE HTML>" > $FILE;
echo "<html lang='en'><head><meta charset='utf-8'>" >> $FILE;
echo "<meta http-equiv='refresh' content='0;url=${NEW_URL}' />" >> $FILE;
echo "<link rel='canonical' href='${NEW_URL}' />" >> $FILE;
echo "</head>" >> $FILE;
echo "<body><p>The page been moved to <a href='${NEW_URL}'>${NEW_URL}</a></p></body>" >> $FILE;
echo "</html>" >> $FILE;
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
if: github.ref == env.default_branch_ref
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: public
force_orphan: true