doc-deploy #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build fractalshades documentation and deploy it to repo | |
# `fractalshades-doc` | |
name: doc-deploy | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "deploy_doc" | |
deploy_doc: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.10"] # , 3.8] | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Prepare install dependencies | |
run: | | |
sudo apt-get update | |
pip install --upgrade pip | |
- name: Prepare GUI | |
run: | | |
echo "Prepare GUI for pyQt6" | |
pip install pyQt6 | |
# See | |
# https://github.com/pytest-dev/pytest-qt/issues/396 | |
# https://github.com/pytest-dev/pytest-qt/pull/295/files | |
# https://github.com/konserw/mre/blob/master/.github/workflows/linux.yml | |
# https://moderngl.readthedocs.io/en/5.6.3/techniques/headless_ubuntu_18_server.html | |
sudo apt-get install xvfb mesa-utils libegl1-mesa | |
sudo apt-get install libxkbcommon-x11-0 | |
sudo apt-get install --reinstall libxcb-xinerama0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 | |
- name: Install GMP MPFR MPC needed for gmpy2 | |
run: | | |
sudo apt-get install libgmp-dev | |
sudo apt-get install libmpfr-dev | |
sudo apt-get install libmpc-dev | |
- name: Install Latex | |
run: | | |
sudo apt-get install dvipng | |
sudo apt-get install texlive | |
sudo apt-get install texlive-latex-extra | |
- name: Install python modules build & test dependencies | |
run: | | |
pip install --upgrade pip | |
pip install --upgrade build | |
pip install flake8 pytest | |
- name: install Fractalshades from current commit | |
run: | | |
# Step 1 build | |
python3 -m build | |
# Step 2 install | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
python3 -m pip install fractalshades --user --force-reinstall --no-deps --no-index --find-links dist | |
- name: install dependencies to build the documentation | |
run: | | |
python -m pip install sphinx sphinx_rtd_theme sphinx-gallery numpydoc matplotlib sphinxcontrib-bibtex sphinxcontrib-youtube | |
# Dependencies for fractalshades.movie | |
python -m pip install av scipy | |
- name: Build the doc and publish it | |
run: | | |
echo "###################################" | |
echo "Download previous status of examples from repo fractalshades-doc" | |
build_dir=`pwd` | |
deploy_dir=`mktemp -d` | |
pushd "${deploy_dir}" | |
git config --global user.email "[email protected]" | |
git config --global user.name "GBillotey" | |
git clone "https://token:${{ secrets.DOC_PUSH_TOKEN }}@github.com/${{ github.repository }}-doc.git" . | |
# Here we check that doc-latest branch exists, and if yes, copy the files before building | |
# https://stackoverflow.com/questions/8223906/how-to-check-if-remote-branch-exists-on-a-given-remote-repository | |
if git ls-remote --heads origin doc-latest-data; then | |
echo 'Branch doc-latest-data exists in remote, copying files' | |
git checkout doc-latest-data | |
# Exclude git tracking files | |
rsync -av --exclude '.git' . "${build_dir}"/docs/examples/ | |
else | |
echo 'Branch doc-latest-data does not exists in remote, create empty dir' | |
mkdir "${build_dir}"/docs/examples/ | |
fi | |
popd | |
echo "###################################" | |
echo "Build the doc in build repo" | |
# Note: /!\ run with QT_QPA_PLATFORM=offscreen on a headless runner | |
make -C docs clean | |
QT_QPA_PLATFORM=offscreen make -C docs html | |
echo "###################################" | |
echo "Push the html doc to doc repository, branch doc-latest" | |
pushd "${deploy_dir}" | |
# don't bother maintaining history; just generate fresh in an orphan branch | |
git switch --orphan temp_data_branch | |
rsync -av "${build_dir}/docs/_build/html/" . | |
git add -A | |
git commit -m "Automatic triggered doc build - ${{ github.workflow }}" | |
git branch -m doc-latest | |
git push --force origin doc-latest | |
echo "###################################" | |
echo "Push the examples data to doc repository, branch doc-latest-data" | |
git switch --orphan temp_data_branch | |
rsync -av "${build_dir}/docs/examples/" . | |
git add -A | |
git commit -m "Automatic triggered doc build - ${{ github.workflow }}" | |
if git ls-remote --heads origin doc-latest-data; then | |
git branch -D doc-latest-data | |
fi | |
git branch -m doc-latest-data | |
git push --force origin doc-latest-data | |
popd |