Merge pull request #11 from AlexHls/fix-headless #61
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
name: docs | |
# Controls when the workflow will run | |
on: | |
push: | |
branches: | |
- master | |
pull_request_target: | |
branches: | |
- master | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- labeled # requires the `build-docs` label | |
workflow_dispatch: # manual trigger | |
env: | |
CACHE_NUMBER: 0 # increase to reset cache manually | |
DEPLOY_BRANCH: gh-pages # deployed docs branch | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash -l {0} | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
build-docs: | |
if: github.event_name == 'push' || | |
github.event_name == 'workflow_dispatch' || | |
(github.event_name == 'pull_request_target' && | |
contains(github.event.pull_request.labels.*.name, 'build-docs')) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10"] | |
# 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@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: r-lib/actions/setup-pandoc@v1 | |
with: | |
pandoc-version: '2.7.3' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pytest | |
if [ -f sccala-env.txt ]; then pip install -r sccala-env.txt; fi | |
pip install sphinx sphinx-autoapi sphinx-rtd-theme nbsphinx pandoc | |
- name: Install package | |
run: pip install -e . | |
- name: Set profiling option | |
run: | | |
if [[ $EVENT == pull_request_target ]]; then | |
echo "DISABLE_PROFILING=1" >> $GITHUB_ENV | |
else | |
echo "DISABLE_PROFILING=0" >> $GITHUB_ENV | |
fi | |
cat $GITHUB_ENV | |
env: | |
EVENT: ${{ github.event_name }} | |
- name: Build documentation | |
run: cd docs/ && make html CORES=auto | |
- name: Set destination directory | |
run: | | |
BRANCH=$(echo ${GITHUB_REF#refs/heads/}) | |
if [[ $EVENT == push ]] || [[ $EVENT == workflow_dispatch ]]; then | |
if [[ $BRANCH == $DEFAULT ]]; then | |
echo "DEST_DIR=" >> $GITHUB_ENV | |
else | |
echo "DEST_DIR=branch/$BRANCH" >> $GITHUB_ENV | |
fi | |
elif [[ $EVENT == pull_request_target ]]; then | |
echo "DEST_DIR=pull/$PR" >> $GITHUB_ENV | |
else | |
echo "Unexpected event trigger $EVENT" | |
exit 1 | |
fi | |
cat $GITHUB_ENV | |
env: | |
DEFAULT: ${{ github.event.repository.default_branch }} | |
EVENT: ${{ github.event_name }} | |
PR: ${{ github.event.number }} | |
- name: Set clean branch option | |
run: | | |
if [[ $EVENT == workflow_dispatch ]]; then | |
echo "CLEAN_BRANCH=true" >> $GITHUB_ENV | |
else | |
echo "CLEAN_BRANCH=false" >> $GITHUB_ENV | |
fi | |
cat $GITHUB_ENV | |
env: | |
EVENT: ${{ github.event_name }} | |
- name: Deploy ${{ env.DEST_DIR }} | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_branch: ${{ env.DEPLOY_BRANCH }} | |
publish_dir: ./docs/_build/html | |
destination_dir: ${{ env.DEST_DIR }} | |
keep_files: true | |
force_orphan: ${{ env.CLEAN_BRANCH }} |