Repository navigation
Merge pull request #25 from ci-sourcerer/feat/versioned-zensical-docs #8
This file contains hidden or 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: docs-deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| paths: | |
| - '.github/workflows/docs.yml' | |
| - '.github/workflows/docs-deploy.yml' | |
| - 'docs/**' | |
| - 'zensical.toml' | |
| - 'pyproject.toml' | |
| - 'src/common_python_tasks/tasks.py' | |
| workflow_dispatch: | |
| inputs: | |
| source_ref: | |
| description: Optional tag or commit to build for a manual version deployment | |
| required: false | |
| default: '' | |
| type: string | |
| docs_version: | |
| description: Optional version identifier, such as 0.12 | |
| required: false | |
| default: '' | |
| type: string | |
| docs_version_title: | |
| description: Optional version title, such as 0.12.1 | |
| required: false | |
| default: '' | |
| type: string | |
| update_latest: | |
| description: Move the latest alias to this version | |
| required: false | |
| default: false | |
| type: boolean | |
| default_version: | |
| description: Optional version or alias used as the site root | |
| required: false | |
| default: '' | |
| type: string | |
| concurrency: | |
| group: github-pages | |
| cancel-in-progress: false | |
| jobs: | |
| metadata: | |
| name: Resolve documentation version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| aliases: ${{ steps.metadata.outputs.aliases }} | |
| checkout_ref: ${{ steps.metadata.outputs.checkout_ref }} | |
| default_version: ${{ steps.metadata.outputs.default_version }} | |
| version: ${{ steps.metadata.outputs.version }} | |
| version_title: ${{ steps.metadata.outputs.version_title }} | |
| steps: | |
| - name: Resolve version metadata | |
| id: metadata | |
| env: | |
| DEFAULT_VERSION: ${{ inputs.default_version }} | |
| DOCS_VERSION: ${{ inputs.docs_version }} | |
| DOCS_VERSION_TITLE: ${{ inputs.docs_version_title }} | |
| REF_NAME: ${{ github.ref_name }} | |
| REF_TYPE: ${{ github.ref_type }} | |
| SOURCE_REF: ${{ inputs.source_ref }} | |
| UPDATE_LATEST: ${{ inputs.update_latest }} | |
| run: | | |
| if [[ -n "$DOCS_VERSION" ]]; then | |
| manual_inputs="$DOCS_VERSION$DOCS_VERSION_TITLE$SOURCE_REF$DEFAULT_VERSION" | |
| if [[ "$manual_inputs" == *$'\n'* || "$manual_inputs" == *$'\r'* ]]; then | |
| echo 'Manual documentation inputs cannot contain newlines.' >&2 | |
| exit 2 | |
| fi | |
| if [[ "$UPDATE_LATEST" == "true" ]]; then | |
| aliases='["latest"]' | |
| else | |
| aliases='[]' | |
| fi | |
| { | |
| echo "aliases=$aliases" | |
| echo "checkout_ref=$SOURCE_REF" | |
| echo "default_version=$DEFAULT_VERSION" | |
| echo "version=$DOCS_VERSION" | |
| echo "version_title=$DOCS_VERSION_TITLE" | |
| } >> "$GITHUB_OUTPUT" | |
| elif [[ "$REF_TYPE" == "tag" ]]; then | |
| if [[ ! "$REF_NAME" =~ ^v?([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | |
| echo "Stable documentation tags must use vMAJOR.MINOR.PATCH: $REF_NAME" >&2 | |
| exit 2 | |
| fi | |
| { | |
| echo 'aliases=["latest"]' | |
| echo 'checkout_ref=' | |
| echo 'default_version=latest' | |
| echo "version=${BASH_REMATCH[1]}.${BASH_REMATCH[2]}" | |
| echo "version_title=${REF_NAME#v}" | |
| } >> "$GITHUB_OUTPUT" | |
| else | |
| { | |
| echo 'aliases=[]' | |
| echo 'checkout_ref=' | |
| echo 'default_version=' | |
| echo 'version=dev' | |
| echo 'version_title=Development' | |
| } >> "$GITHUB_OUTPUT" | |
| fi | |
| docs: | |
| needs: metadata | |
| uses: ./.github/workflows/docs.yml | |
| with: | |
| python_version: '3.14' | |
| dependency_group: '' | |
| locked: false | |
| artifact_name: common-python-tasks-docs | |
| checkout_ref: ${{ needs.metadata.outputs.checkout_ref }} | |
| generated_docs_check_task: check-docs-references | |
| deploy_github_pages: true | |
| docs_version: ${{ needs.metadata.outputs.version }} | |
| docs_version_title: ${{ needs.metadata.outputs.version_title }} | |
| docs_aliases: ${{ needs.metadata.outputs.aliases }} | |
| docs_default_version: ${{ needs.metadata.outputs.default_version }} | |
| permissions: | |
| contents: write | |
| deployments: write | |
| pages: write | |
| id-token: write |