Skip to content

Improve document workflow #33

Improve document workflow

Improve document workflow #33

Workflow file for this run

name: Deploy Documentation
on:
push:
branches: [main, staging, develop]
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # Fetch all history for mike versioning
- name: Detect tag
id: tag
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: github.ref_name == 'main'
run: |
mike deploy --push --update-aliases latest stable
mike set-default --push latest
- name: Deploy documentation (staging branch)
if: github.ref_name == 'staging'
run: |
mike deploy --push staging
- name: Deploy documentation (develop branch)
if: github.ref_name == 'develop'
run: |
mike deploy --push dev
- name: Set default alias when missing (develop)
if: github.ref_name == '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