Update A2.md #339
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: Build documentation | |
env: | |
CACHE_NUMBER: 1 # increase to reset cache manually | |
on: | |
# Runs on pushes targeting the default branch | |
push: | |
branches: ["main"] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
build: | |
strategy: | |
max-parallel: 2 | |
matrix: | |
include: | |
- os: ubuntu-latest | |
label: linux-64 | |
prefix: $CONDA/bin | |
# - os: windows-latest | |
# label: win-64 | |
# prefix: $CONDA/Scripts | |
name: ${{ matrix.label }} | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -l {0} | |
working-directory: ./ | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.11' | |
- name: Add conda to system path | |
run: | | |
# $CONDA is an environment variable pointing to the root of the miniconda directory | |
echo "Conda directory: $CONDA" | |
echo $CONDA/bin >> $GITHUB_PATH | |
- name: Init conda | |
run: conda init bash | |
- name: Set cache date and path | |
run: | | |
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV | |
echo "CONDA_ENV=$CONDA/envs/docsEnv" >> $GITHUB_ENV | |
# echo "CONDA_ENV=$CONDA/envs/BIMEnv" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.CONDA_ENV }} | |
key: ${{ matrix.label }}-conda-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }} | |
id: cache | |
- name: Set up conda environment if no cache hit | |
run: | | |
# Install dependencies | |
conda env update -n docsEnv -f ./environment.yml | |
echo "CONDA_PREFIX: $CONDA_PREFIX" | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Fetch environment cache | |
run: | | |
echo "CONDA_PKG=$CONDA/envs/docsEnv/conda-bld" >> $GITHUB_ENV | |
- uses: actions/cache/restore@v3 | |
with: | |
path: ${{ env.CONDA_PKG }} | |
key: ${{ matrix.label }}-conda-pkg-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }} | |
id: restore-cache | |
- name: Add local channel linux-64 | |
run: | | |
source activate docsEnv | |
conda activate docsEnv | |
# source activate BIMEnv | |
# conda activate BIMEnv | |
conda config --add channels file://${{ env.CONDA_PKG }} | |
- name: Setup Pages | |
id: pages | |
uses: actions/configure-pages@v3 | |
- name: Build with Sphinx | |
run: | | |
source activate docsEnv | |
conda activate docsEnv | |
echo "CONDA_PREFIX: $CONDA_PREFIX" | |
echo "Sphinx-build version: $(sphinx-build --version)" | |
sphinx-build -M html ./ _build/ | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: _build/html/ | |
# Deployment job | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |