diff --git a/.github/actions/build-docs/action.yml b/.github/actions/build-docs/action.yml index 649a4c2f0ba..b17d156d119 100644 --- a/.github/actions/build-docs/action.yml +++ b/.github/actions/build-docs/action.yml @@ -5,10 +5,6 @@ inputs: description: 'Whether the linkchecker should be run' required: false default: 'false' - upload-build: - description: 'Whether the build of the docs should be uploaded as an artifact.' - required: false - default: 'true' key: description: 'Key to use for artifacts' required: false @@ -17,6 +13,9 @@ outputs: log_available: description: 'Whether a log from the doc build is available' value: ${{ steps.builddocs.outputs.log_available == 'true' || steps.linkchecker.outputs.log_available == 'true'}} + doc_version: + description: 'What version the docs correspond to' + value: ${{ steps.docversion.outputs.doc_version }} runs: using: composite steps: @@ -50,8 +49,13 @@ runs: [ ! -s build/linkcheck/output.txt ] || (cp build/linkcheck/output.txt linkchecker.log && echo '::set-output name=log_available::true' && false) popd + - name: Set doc version + id: docversion + shell: bash -l {0} + run: echo "::set-output name=doc_version::v$(python -c 'import metpy,re; print(re.search(r"(\d+\.\d+)", metpy.__version__)[0])')" + - name: Upload docs as artifact - if: ${{ inputs.upload-build == 'true' }} + if: ${{ always() && inputs.key != '' }} uses: actions/upload-artifact@v2 with: name: ${{ inputs.key }}-docs diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index aed988306a2..24e96bd6400 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -21,11 +21,9 @@ jobs: # Docs: name: ${{ matrix.python-version }} ${{ matrix.dep-versions }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: DOC_VERSION: dev - environment: - name: github-pages strategy: fail-fast: false matrix: @@ -36,6 +34,8 @@ jobs: - python-version: 3.9 check-links: true dep-versions: requirements.txt + outputs: + doc_version: ${{ steps.build-docs.outputs.doc-version }} steps: # We check out only a limited depth and then pull tags to save time @@ -58,20 +58,34 @@ jobs: python-version: ${{ matrix.dep-versions }} - name: Build docs + id: build-docs uses: ./.github/actions/build-docs with: run-linkchecker: ${{ github.event_name == 'pull_request' && matrix.check-links == true }} - upload-build: ${{ github.event_name == 'pull_request' }} key: ${{ runner.os }}-${{ matrix.python-version }} + Deploy: + if: ${{ github.event_name != 'pull_request' }} + needs: Docs + environment: + name: github-pages + runs-on: ubuntu-latest + env: + DOC_VERSION: dev + + steps: + - name: Download doc build + uses: actions/download-artifact@v2 + with: + name: Linux-3.9-docs + # This overrides the version "dev" with the proper version if we're building off a # branch that's not main (which is confined to n.nn.x above) or on a tag. - name: Set doc version if: ${{ github.event_name != 'push' || !contains(github.ref, 'main') }} - run: echo "DOC_VERSION=v$(python -c 'import metpy,re; print(re.search(r"(\d+\.\d+)", metpy.__version__)[0])')" >> $GITHUB_ENV + run: echo "DOC_VERSION=v${{ needs.Docs.outputs.doc-version }}" >> $GITHUB_ENV - name: Upload to GitHub Pages - if: ${{ github.event_name != 'pull_request' && matrix.python-version == '3.9' }} uses: peaceiris/actions-gh-pages@v3.8.0 with: deploy_key: ${{ secrets.GHPAGES_DEPLOY_KEY }}