Skip to content

docs

docs #1874

Workflow file for this run

name: Build & publish docs
on:
push:
branches:
- master
repository_dispatch:
types: [docs]
workflow_dispatch:
jobs:
build:
name: Build docs
runs-on: ubuntu-latest
strategy:
matrix:
# you must not use anything but include here or the version.json generation will fail!
include:
- version: "1.10.3"
source: "tags"
python: "3.10"
sphinx: "4.5.0"
mermaid: "0.7.1"
jinja: "3.1.1"
mermaid_fix: "true"
- version: "master"
source: "heads"
python: "3.10"
sphinx: "4.5.0"
mermaid: "0.7.1"
jinja: "3.1.1"
mermaid_fix: "true"
- version: "maintenance"
source: "heads"
python: "3.10"
sphinx: "4.5.0"
mermaid: "0.7.1"
jinja: "3.1.1"
mermaid_fix: "true"
- version: "devel"
source: "heads"
python: "3.10"
sphinx: "4.5.0"
mermaid: "0.7.1"
jinja: "3.1.1"
mermaid_fix: "true"
steps:
- name: 🧾 Log event & matrix
run: |
echo "Event: ${{ github.event_name }} - ${{ toJson(github.event.client_payload) }}"
echo "Matrix: ${{ matrix.version }}, ${{ matrix.source }}, ${{ matrix.python }}, ${{ matrix.mermaid }}, ${{ matrix.mermaid_fix }}"
echo "Formatted ref: ${{ format('refs/{0}/{1}', matrix.source, matrix.version) }}"
- name: ⬇ Checkout docs.octoprint.org
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
uses: actions/checkout@v4
with:
path: docs.octoprint.org
- name: πŸ‘€ Determine latest OctoPrint release
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
run: |
OCTOPRINT_VERSION=$(curl -i https://github.com/OctoPrint/OctoPrint/releases/latest | grep -i location: | head -n1 | awk -F/ '{print $NF}' | tr -d '\r')
echo "OCTOPRINT_VERSION=$OCTOPRINT_VERSION" >> $GITHUB_ENV
- name: 🐍 Set up Python ${{ matrix.python }}
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: 🐍 Preinstall some dependencies
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
run: |
pip install sphinx==${{ matrix.sphinx }} sphinxcontrib-mermaid==${{ matrix.mermaid }} Jinja2==${{ matrix.jinja }}
- name: πŸ— Set up NodeJS
if: matrix.mermaid_fix == 'true' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version))
uses: actions/setup-node@v3
with:
node-version: "16"
- name: πŸ— Install mermaid-cli
if: matrix.mermaid_fix == 'true' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version))
run: |
npm install @mermaid-js/mermaid-cli
- name: ⬇ Checkout OctoPrint
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
uses: actions/checkout@v4
with:
repository: "OctoPrint/OctoPrint"
ref: ${{ matrix.version }}
path: OctoPrint
- name: πŸ— Install OctoPrint
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
run: |
cd ${{ github.workspace }}/OctoPrint
pip install .[develop,docs]
- name: πŸ”„ Generate versions.json
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
run: |
python ${{ github.workspace }}/docs.octoprint.org/util/versions_from_matrix.py ${{ github.workspace }}/docs.octoprint.org/.github/workflows/docs.yaml versions.json
- name: πŸ— Build docs
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
run: |
cd ${{ github.workspace }}/docs.octoprint.org/util/versionselector
if [[ "${{ matrix.mermaid_fix }}" == "true" ]]; then
python versionselector.py ${{ github.workspace }}/OctoPrint/docs/ ${{ matrix.version }} ${{ env.OCTOPRINT_VERSION }} ${{ github.workspace }}/versions.json -D mermaid_cmd=${{ github.workspace }}/node_modules/.bin/mmdc -D mermaid_output_format=svg -D mermaid_version=
echo ".rst-content object[type^='image/']{width: 100%;}" >> ${{ github.workspace }}/OctoPrint/docs/_build/html/${{ matrix.version }}/_static/theme_overrides.css
else
python versionselector.py ${{ github.workspace }}/OctoPrint/docs/ ${{ matrix.version }} ${{ env.OCTOPRINT_VERSION }} ${{ github.workspace }}/versions.json
fi
#- name: πŸ”Ž Run link check
# id: lc
# uses: peter-evans/link-checker@v1
# with:
# args: -v -r -d ./OctoPrint/docs/_build/html/${{ matrix.version }} ./OctoPrint/docs/_build/html/${{ matrix.version }}
#- name: πŸ”Ž Evaluate link check
# run: exit ${{ steps.lc.outputs.exit_code }}
- name: ⬆ Persist build result
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.version }}
path: ${{ github.workspace }}/OctoPrint/docs/_build/html/${{ matrix.version }}
deploy:
name: Deploy docs
needs: build
runs-on: ubuntu-latest
steps:
- name: ⬇ Checkout docs.octoprint.org
uses: actions/checkout@v4
with:
ref: gh-pages
path: docs
- name: ⬇ Fetch all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: 🧹 Cleanup all docs
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: |
count=`ls -1 artifacts | wc -l`
if [ $count != '0' ]; then
rm -rf docs/* || true
touch docs/.nojekyll
cp -rv artifacts/* docs
fi
- name: 🧹 Cleanup regenerated docs
if: github.event_name == 'repository_dispatch'
run: |
version="${{ github.event.client_payload.ref }}"
version=${version#"refs/heads/"}
version=${version#"refs/tags/"}
echo "Version is $version"
if [ -d "artifacts/$version" ]; then
rm -rf docs/$version || true
cp -r artifacts/$version docs/
fi
- name: πŸš€ Commit & deploy
uses: EndBug/add-and-commit@v9
with:
cwd: "docs"
message: "Publish new build of docs"
default_author: github_actions