Skip to content

v2.12.1 A Fond Farewell to CDAT #35

v2.12.1 A Fond Farewell to CDAT

v2.12.1 A Fond Farewell to CDAT #35

name: CI/CD Release Workflow
on:
release:
types: [published]
workflow_dispatch:
jobs:
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:
# Increase this value to reset cache if conda-env/ci.yml has not changed in the workflow
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('conda-env/ci.yml') }}
- name: Set up Conda Environment
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: "e3sm_diags_ci"
miniforge-variant: Miniforge3
miniforge-version: latest
environment-file: conda-env/ci.yml
channel-priority: strict
auto-update-conda: true
- 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/e3sm_diags.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
# Replace main docs to populate dropdown with latest tags
rm -r _build/html/main
# Only copy docs for main and current tag
cp -r -n ../docs/_build/html _build/
# 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