Fix Sphinx linkcheck in build.yaml #5
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
name: Build Tutorials | |
on: | |
push: | |
branches: [ master ] | |
tags: ["*"] | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
inputs: | |
run_deploy: | |
description: 'Should newest tag be deployed?' | |
required: false | |
default: "" | |
defaults: | |
run: | |
shell: bash -leo pipefail {0} {0} | |
jobs: | |
find-tag: | |
runs-on: ubuntu-latest | |
outputs: | |
latest-tag: ${{ steps.find-tag.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- id: find-tag | |
run: echo "tag=$(git describe --tags `git rev-list --tags --max-count=1`)" >> "$GITHUB_OUTPUT" | |
link-check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install mamba | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-file: environment.yaml | |
- run: sphinx-build -M linkcheck . _build -W --keep-going -a -q | |
link-check-last-tagged: | |
runs-on: ubuntu-latest | |
needs: find-tag | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.find-tag.outputs.latest-tag }} | |
- name: Install mamba | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-file: environment.yaml | |
- run: sphinx-build -M linkcheck . _build -W --keep-going -a -q | |
build: | |
runs-on: ubuntu-latest | |
needs: [find-tag, link-check] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install mamba | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-file: environment.yaml | |
- name: Build Documentation | |
run: | | |
sphinx-build -M html . _build-beta -W --keep-going -a -t draft | |
- name: Checkout last tagged | |
run: | | |
git checkout ${{ needs.find-tag.outputs.latest-tag }} | |
- name: Build environment for last tagged version | |
run: micromamba create -n tutorial-tagged -y -f environment.yaml | |
- name: Build last tagged version | |
run: | | |
micromamba activate tutorial-tagged | |
sphinx-build -M html . _build -W --keep-going -a | |
- name: Prepare html for upload | |
run: | | |
mkdir -p gh-pages/beta | |
cp -rT _build-beta/html gh-pages/beta | |
cp -rT _build/html gh-pages | |
- uses: actions/upload-pages-artifact@v2 | |
with: | |
path: gh-pages | |
deploy: | |
needs: [build, link-check-last-tagged] | |
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 | |