Zensical docs workflow run #141
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: Documentation Deploy | |
| on: | |
| repository_dispatch: | |
| types: [maintainerr-release] | |
| workflow_dispatch: | |
| inputs: | |
| versionInput: | |
| description: 'What version of Maintainerr are these docs for?' | |
| required: true | |
| isDev: | |
| description: 'Is this a dev version?' | |
| required: true | |
| type: boolean | |
| pull_request: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| if: github.event.repository.fork == false | |
| steps: | |
| - uses: actions/configure-pages@v5 | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.ref || github.ref}} | |
| sparse-checkout: | | |
| docs | |
| layouts | |
| - name: Validate Version Input | |
| run: | | |
| VERSION="${{ github.event.inputs.versionInput || github.event.client_payload.versionInput }}" | |
| if [[ ! "$VERSION" =~ ^[a-zA-Z0-9._-]+$ ]]; then | |
| echo "Invalid version format: '$VERSION'" | |
| echo "Allowed characters: letters, numbers, dots (.), hyphens (-), and underscores (_)" | |
| exit 1 | |
| fi | |
| echo "Version format is valid: $VERSION" | |
| - name: Configure Git Credentials | |
| run: | | |
| git config user.name github-actions[bot] | |
| git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.x | |
| - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV | |
| - uses: actions/cache@v4 | |
| with: | |
| key: mkdocs-material-${{ env.cache_id }} | |
| path: .cache | |
| restore-keys: | | |
| mkdocs-material- | |
| - run: pip install zensical | |
| - run: zensical build --clean | |
| - uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: site | |
| - uses: actions/deploy-pages@v4 | |
| - name: Deploy Documentation | |
| run: | | |
| VERSION="${{ github.event.inputs.versionInput || github.event.client_payload.versionInput }}" | |
| if [ "${{ github.event_name }}" == "repository_dispatch" ]; then | |
| mike deploy --update-aliases "$VERSION" latest | |
| else | |
| if [ "${{ github.event.inputs.isDev }}" == "false" ]; then | |
| mike deploy --update-aliases "$VERSION" latest | |
| else | |
| mike deploy --push --update-aliases "$VERSION" dev | |
| fi | |
| fi | |
| - name: Set Default Version to Latest | |
| if: github.event_name == 'repository_dispatch' || github.event.inputs.isDev == 'false' | |
| run: mike set-default --push --allow-empty latest | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} |