Skip to content

v1.4.1

v1.4.1 #19

name: CI/CD Release Workflow
on:
# This is run on release, meaning it is run when these steps are followed:
# https://e3sm-project.github.io/zstash/_build/html/main/dev_guide/release.html#releasing-on-github-production-releases
# That means this workflow is not run for release candidates.
release:
types: [published]
jobs:
# On a release, the docs should always be published.
publish-docs:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Cache Conda
uses: actions/cache@v3
env:
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('conda/dev.yml') }}
- name: Build Conda Environment
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: zstash_dev
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
mamba-version: "*"
environment-file: conda/dev.yml
channel-priority: strict
auto-update-conda: true
# sphinx-multiversion allows for version docs.
- name: Build Sphinx Docs
run: |
cd docs
sphinx-multiversion source _build/html
- name: Copy Docs and Commit
run: |
# gh-pages branch must already exist
git clone https://github.com/E3SM-Project/zstash.git --branch gh-pages --single-branch gh-pages
# Make sure we're in the gh-pages directory.
cd gh-pages
# Create `.nojekyll` (if it doesn't already exist) for proper GH Pages configuration.
touch .nojekyll
# Add `index.html` to point to the `main` branch automatically.
printf '<meta http-equiv="refresh" content="0; url=./_build/html/main/index.html" />' > index.html
# Only replace `main` docs with latest changes. Docs for tags should be untouched.
rm -rf _build/html/main
mkdir -p _build/html/main
cp -r ../docs/_build/html/main _build/html
# Configure git using GitHub Actions credentials.
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# The below command will fail if no changes were present, so we ignore it
git add .
git commit -m "Update documentation" -a || true
- name: Push Changes
uses: ad-m/github-push-action@master
with:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true