Update GitHub Pages build logic #50
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 | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| - develop | |
| - 'release/**' | |
| tags: | |
| - '*.*.*' | |
| - '*.*.*-*' | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: write # allow pushing to gh-pages | |
| concurrency: | |
| group: docs | |
| cancel-in-progress: false | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # needed by mike to manage gh-pages history | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Install MkDocs and plugins | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install mkdocs mkdocs-material mike mkdocs-roamlinks-plugin pymdown-extensions | |
| - name: Setup GitVersion | |
| uses: gittools/actions/gitversion/setup@v0 | |
| with: | |
| versionSpec: '5.x' | |
| - name: Determine version via GitVersion | |
| id: gitversion | |
| uses: gittools/actions/gitversion/execute@v0 | |
| - name: Configure git author | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Deploy documentation with mike | |
| env: | |
| GITHUB_REF: ${{ github.ref }} | |
| SEMVER: ${{ steps.gitversion.outputs.SemVer }} | |
| run: | | |
| set -e | |
| echo "Ref: $GITHUB_REF" | |
| echo "SemVer: $SEMVER" | |
| if [[ "$GITHUB_REF" == refs/tags/* ]]; then | |
| # Tag push -> deploy as the tag name | |
| VERSION="${GITHUB_REF#refs/tags/}" | |
| if [[ "$VERSION" == *-* ]]; then | |
| # Pre-release tag (e.g. 3.5.0-beta.1) -> deploy without aliasing to 'latest' | |
| mike deploy --push "$VERSION" | |
| else | |
| # Stable release tag (e.g. 3.5.0) -> deploy and alias to 'latest' | |
| mike deploy --push --update-aliases "$VERSION" latest | |
| fi | |
| elif [[ "$GITHUB_REF" == refs/heads/master ]] || [[ "$GITHUB_REF" == refs/heads/main ]]; then | |
| # Main/master -> deploy as the GitVersion SemVer and alias to 'latest' | |
| VERSION="$SEMVER" | |
| mike deploy --push --update-aliases "$VERSION" latest | |
| mike set-default latest --push | |
| elif [[ "$GITHUB_REF" == refs/heads/develop ]]; then | |
| # Develop -> rolling 'alpha' alias pointing to the GitVersion-computed SemVer | |
| VERSION="$SEMVER" | |
| mike deploy --push --update-aliases "$VERSION" alpha | |
| elif [[ "$GITHUB_REF" == refs/heads/release/* ]]; then | |
| # Any release/* -> rolling 'beta' alias pointing to the GitVersion-computed SemVer | |
| VERSION="$SEMVER" | |
| mike deploy --push --update-aliases "$VERSION" beta | |
| else | |
| echo "Branch not configured for docs deployment; skipping." | |
| fi |