Deploy Documentation #32
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: Deploy Documentation | |
| on: | |
| workflow_run: | |
| workflows: | |
| - Tests | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| deploy: | |
| if: > | |
| github.event_name == 'workflow_dispatch' || | |
| ( | |
| github.event_name == 'workflow_run' && | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.event == 'push' && | |
| ( | |
| github.event.workflow_run.head_branch == 'main' || | |
| github.event.workflow_run.head_branch == 'staging' || | |
| github.event.workflow_run.head_branch == 'develop' || | |
| github.event.workflow_run.head_branch == '' || | |
| github.event.workflow_run.head_branch == null | |
| ) | |
| ) | |
| runs-on: ubuntu-latest | |
| env: | |
| TARGET_BRANCH: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 # Fetch all history for mike versioning | |
| - name: Detect tag (workflow_run) | |
| id: tag | |
| if: env.TARGET_BRANCH == '' | |
| run: | | |
| TAG=$(git describe --tags --exact-match 2>/dev/null || true) | |
| echo "value=$TAG" >> "$GITHUB_OUTPUT" | |
| - name: Configure Git Credentials | |
| run: | | |
| git config user.name github-actions[bot] | |
| git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.x' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[docs]" | |
| - name: Deploy documentation (main branch) | |
| if: env.TARGET_BRANCH == 'main' | |
| run: | | |
| mike deploy --push --update-aliases latest stable | |
| mike set-default --push latest | |
| - name: Deploy documentation (staging branch) | |
| if: env.TARGET_BRANCH == 'staging' | |
| run: | | |
| mike deploy --push staging | |
| - name: Deploy documentation (develop branch) | |
| if: env.TARGET_BRANCH == 'develop' | |
| run: | | |
| mike deploy --push dev | |
| - name: Set default alias when missing (develop) | |
| if: env.TARGET_BRANCH == 'develop' | |
| run: | | |
| DEFAULT_ALIAS=$(mike list --remote 2>/dev/null | awk '/^\*/ {print $2}') | |
| if [ -z "$DEFAULT_ALIAS" ]; then | |
| mike set-default --push dev | |
| fi | |
| - name: Deploy documentation (version tag) | |
| if: steps.tag.outputs.value != '' | |
| run: | | |
| VERSION=${{ steps.tag.outputs.value }} | |
| VERSION=${VERSION#v} | |
| mike deploy --push --update-aliases $VERSION stable | |
| mike set-default --push $VERSION |