From ae2c0a292e3a14212befa04a7b66e26a4e074ecf Mon Sep 17 00:00:00 2001 From: jprestop Date: Thu, 17 Jun 2021 15:13:09 -0600 Subject: [PATCH] Feature 1819 automation doc warnings (#1836) --- .github/jobs/build_documentation.sh | 25 +++++++++++++++++++ .../workflows/{main.yml => documentation.yml} | 22 +++++----------- 2 files changed, 31 insertions(+), 16 deletions(-) create mode 100755 .github/jobs/build_documentation.sh rename .github/workflows/{main.yml => documentation.yml} (59%) diff --git a/.github/jobs/build_documentation.sh b/.github/jobs/build_documentation.sh new file mode 100755 index 0000000000..c6b73500a2 --- /dev/null +++ b/.github/jobs/build_documentation.sh @@ -0,0 +1,25 @@ +#! /bin/bash + +# path to docs directory relative to top level of repository +# $GITHUB_WORKSPACE is set if the actions/checkout@v2 action is run first + +DOCS_DIR=${GITHUB_WORKSPACE}/met/docs + +# run Make to build the documentation and return to previous directory +cd ${DOCS_DIR} +make clean html +cd - + +# copy HTML output into directory to create an artifact +mkdir -p artifact/documentation +cp -r ${DOCS_DIR}/_build/html/* artifact/documentation + +# check if the warnings.log file is empty +# Copy it into the artifact and documentation directories +# so it will be available in the artifacts +warning_file=${DOCS_DIR}/_build/warnings.log +if [ -s $warning_file ]; then + cp -r ${DOCS_DIR}/_build/warnings.log artifact/doc_warnings.log + cp artifact/doc_warnings.log artifact/documentation + exit 1 +fi diff --git a/.github/workflows/main.yml b/.github/workflows/documentation.yml similarity index 59% rename from .github/workflows/main.yml rename to .github/workflows/documentation.yml index d959c9e411..62c284aded 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/documentation.yml @@ -1,4 +1,4 @@ -name: MET CI/CD Workflow +name: Documentation on: push: branches: @@ -7,6 +7,8 @@ on: - feature_* - main_* - bugfix_* + paths: + - met/docs/** pull_request: types: [opened, reopened, synchronize] @@ -24,26 +26,14 @@ jobs: python -m pip install --upgrade python-dateutil requests sphinx \ sphinx-gallery Pillow sphinx_rtd_theme - name: Build docs - continue-on-error: true - run: | - DOCS_DIR=${GITHUB_WORKSPACE}/met/docs - cd ${DOCS_DIR} - make clean html - cd ${GITHUB_WORKSPACE} - warning_file=${DOCS_DIR}/_build/warnings.log - mkdir -p artifact/documentation - cp -r ${DOCS_DIR}/_build/html/* artifact/documentation - if [ -s $warning_file ]; then - cp -r ${DOCS_DIR}/_build/warnings.log artifact/doc_warnings.log - cp artifact/doc_warnings.log artifact/documentation - else - rm ${warning_file} - fi + run: ./.github/jobs/build_documentation.sh - uses: actions/upload-artifact@v2 + if: always() with: name: documentation path: artifact/documentation - uses: actions/upload-artifact@v2 + if: failure() with: name: documentation_warnings.log path: artifact/doc_warnings.log