Skip to content

Merge pull request #48 from brainprepdesk/dev #223

Merge pull request #48 from brainprepdesk/dev

Merge pull request #48 from brainprepdesk/dev #223

Workflow file for this run

# Workflow to build doc, upload it as artifact, and deploy it for the
# master, main and dev branches.
#
# To run this check locally from the `doc` folder:
#
# .. code-block:: bash
#
# $ sphinxdoc -v 2 -p $MODULE_DIR -n brainprep -o $MODULE_DIR/doc
# $ cd $MODULE_DIR/doc
# $ make html-strict
###
name: "DocumentationBuilder"
on:
push:
branches:
- "master"
- "main"
- "dev"
pull_request:
branches:
- "*"
workflow_dispatch:
env:
MIN_PYTHON_VERSION: "3.12"
jobs:
build_and_deploy:
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
env:
FREESURFER_HOME: "/freesurfer/home"
permissions:
contents: write
steps:
- name: Extract branch name
id: extract-branch
shell: bash
run: echo "BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
- name: Identify deploy type
id: deploy-type
run: |
if ${{ github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/main' }}; then
echo "DEPLOY_TYPE=stable" >> $GITHUB_OUTPUT
elif ${{ github.ref == 'refs/heads/dev' }}; then
echo "DEPLOY_TYPE=dev" >> $GITHUB_OUTPUT
else
echo "DEPLOY_TYPE=pr" >> $GITHUB_OUTPUT
fi
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.MIN_PYTHON_VERSION }}
cache: "pip"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --progress-bar off ".[ci,doc]"
- name: Install apt packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: dvipng texlive-latex-base texlive-latex-extra build-essential
version: 1.0
- name: Install documentation resources
run: |
DIR=$(pwd)
which python
sphinxdoc -v 2 -p $DIR -n brainprep -o $DIR/doc
- name: Compute documentation
run: |
DIR=$(pwd)
cd $DIR/doc
echo "Documentation folder: $DIR/doc"
make html-strict
cd $DIR
- name: Upload documentation as an artifact
uses: actions/upload-artifact@v4
env:
DEPLOY_TYPE: ${{ steps.deploy-type.outputs.DEPLOY_TYPE }}
with:
name: doc-${{ env.DEPLOY_TYPE }}
retention-days: 1
path: |
doc/_build/html
- name: Deploy
env:
DEPLOY_TYPE: ${{ steps.deploy-type.outputs.DEPLOY_TYPE }}
if: env.DEPLOY_TYPE != 'pr'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: doc/_build/html
destination_dir: ./${{ env.DEPLOY_TYPE }}