Build and Deploy Docs #65
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: Build and Deploy Docs | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_run: | |
| workflows: ["Publish Plugin"] | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| deployment_type: | |
| description: "Type of docs to deploy" | |
| required: true | |
| type: choice | |
| options: | |
| - dev | |
| - versioned | |
| concurrency: | |
| group: docs-deployment | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 0 # fetch all commits/branches for version history | |
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | |
| with: | |
| python-version: 3.x | |
| - name: Cache MkDocs Material | |
| run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV | |
| - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| key: mkdocs-material-${{ env.cache_id }} | |
| path: .cache | |
| restore-keys: | | |
| mkdocs-material- | |
| - name: Obtain version from build.gradle | |
| id: get_version | |
| run: | | |
| if [ -f build.gradle ]; then | |
| VERSION=$(grep "version = " build.gradle | sed -e 's/version = //' | tr -d "'" | tr -d '"' | xargs) | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "tag=v${VERSION}" >> $GITHUB_OUTPUT | |
| echo "Detected version: $VERSION" | |
| else | |
| echo "version=dev" >> $GITHUB_OUTPUT | |
| echo "tag=dev" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup git user | |
| run: | | |
| git config --global user.name "${{ github.actor }}" | |
| git config --global user.email "${{ github.actor }}@users.noreply.github.com" | |
| - name: Install dependencies | |
| run: pip install mkdocs-material pymdown-extensions mike | |
| - name: Build and deploy versioned docs | |
| if: | | |
| (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || | |
| (github.event_name == 'workflow_dispatch' && inputs.deployment_type == 'versioned') | |
| run: | | |
| mike deploy --push --update-aliases ${{ steps.get_version.outputs.version }} latest | |
| mike set-default --push latest | |
| echo "✅ Deployed versioned docs for v${{ steps.get_version.outputs.version }}" | |
| - name: Build and deploy dev docs | |
| if: | | |
| (github.event_name == 'push') || | |
| (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion != 'success') || | |
| (github.event_name == 'workflow_dispatch' && inputs.deployment_type == 'dev') | |
| run: | | |
| mike deploy --push --update-aliases dev | |
| echo "✅ Deployed dev docs" |