Download tardis main repo for refdata #376
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
# For more information about TARDIS pipelines, please refer to: | |
# | |
# https://tardis-sn.github.io/tardis/development/continuous_integration.html | |
name: docs | |
on: | |
push: | |
branches: | |
- '*' | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * 0' # run at midnight every Sunday | |
concurrency: | |
group: docs-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
XUVTOP: /tmp/chianti | |
CHIANTI_DL_URL: https://download.chiantidatabase.org | |
CHIANTI_DB_VER: CHIANTI_v9.0.1_database.tar.gz | |
CMFGEN_DL_URL: http://kookaburra.phyast.pitt.edu/hillier/cmfgen_files | |
CMFGEN_DB_VER: atomic_data_15nov16.tar.gz | |
jobs: | |
build: | |
# The `docs` workflow is triggered when a commit is pushed to any branch | |
# of the main repo or fork, but the `build` job starts when one of these | |
# conditions is met: | |
# | |
# a) the branch is `master` | |
# b) the branch name contains the word `doc(s)` | |
# c) the commit message includes the a valid tag | |
# d) the workflow has been triggered manually | |
if: github.ref == 'refs/heads/master' || | |
github.event_name == 'workflow_dispatch' || | |
contains(github.ref, 'doc') || | |
contains(github.event.head_commit.message, '[build docs]') || | |
contains(github.event.head_commit.message, '[build_docs]') || | |
contains(github.event.head_commit.message, '[build doc]') || | |
contains(github.event.head_commit.message, '[build_doc]') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- uses: actions/cache@v2 | |
with: | |
path: ${{ env.XUVTOP }} | |
key: ${{ env.CHIANTI_DB_VER }} | |
id: chianti-cache | |
- name: Download Chianti database | |
run: | | |
mkdir -p ${{ env.XUVTOP }} | |
wget -q ${{ env.CHIANTI_DL_URL }}/${{ env.CHIANTI_DB_VER }} -O ${{ env.XUVTOP }}/chianti.tar.gz | |
tar -zxf ${{ env.XUVTOP }}/chianti.tar.gz -C ${{ env.XUVTOP }} --warning=none | |
if: steps.chianti-cache.outputs.cache-hit != 'true' | |
- uses: actions/cache@v2 | |
with: | |
path: /tmp/atomic | |
key: ${{ env.CMFGEN_DB_VER }} | |
id: cmfgen-cache | |
- name: Download CMFGEN database | |
run: | | |
wget -q -U "Mozilla/4.0" ${{ env.CMFGEN_DL_URL }}/${{ env.CMFGEN_DB_VER }} -O /tmp/atomic.tar.gz | |
tar -zxf /tmp/atomic.tar.gz -C /tmp | |
if: steps.cmfgen-cache.outputs.cache-hit != 'true' | |
- uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-file: conda-lock.yml | |
init-shell: bash | |
cache-environment: true | |
cache-downloads: true | |
environment-name: carsus | |
- name: Install package | |
shell: bash -l {0} | |
run: pip install -e . | |
- name: Build documentation | |
shell: bash -l {0} | |
run: cd docs/; make html | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: html-dir | |
path: docs/_build/html | |
deploy: | |
needs: build | |
# The website is deployed to the root of the `gh-pages` branch of the main | |
# repository or fork, only after a commit is pushed to the `master` branch, | |
# and the result will be displayed at: | |
# | |
# tardis-sn.github.io/carsus (main repository) | |
# OR <username>.github.io/carsus (forks) | |
if: github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: html-dir | |
path: docs/_build/html | |
- name: Deploy main site | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_branch: gh-pages | |
publish_dir: docs/_build/html | |
force_orphan: true | |
preview: | |
needs: build | |
# Branch preview is only available on forks, and requires at least one of | |
# these conditions to be met: | |
# | |
# a) the branch name contains the word `doc(s)` | |
# b) commit message includes the a valid tag | |
# c) the workflow is triggered manually | |
# | |
# Result will be displayed at: | |
# | |
# <username>.github.io/carsus/branch/<branch-name> | |
if: github.repository_owner != 'tardis-sn' && | |
github.ref != 'refs/heads/master' && ( | |
github.event_name == 'workflow_dispatch' || | |
contains(github.ref, 'doc') || | |
contains(github.event.head_commit.message, '[build docs]') || | |
contains(github.event.head_commit.message, '[build_docs]') || | |
contains(github.event.head_commit.message, '[build doc]') || | |
contains(github.event.head_commit.message, '[build_doc]')) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: html-dir | |
path: docs/_build/html | |
- name: Get branch name | |
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | |
id: get_branch_name | |
- name: Deploy branch site | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_branch: gh-pages | |
publish_dir: docs/_build/html | |
destination_dir: branch/${{ steps.get_branch_name.outputs.branch }} | |
force_orphan: false |