Skip to content

Publish docs

Publish docs #1622

Workflow file for this run

name: Publish docs
on:
push:
branches:
- main
tags:
- '*'
paths:
- '**.md'
- 'docs/**'
pull_request:
workflow_run:
workflows:
- Build
types:
- completed
branches:
- main
workflow_dispatch:
inputs:
version:
description: 'Docs version to deploy'
required: true
type: string
aliases:
description: 'Optional comma-separated aliases to deploy, such as latest or dev'
required: false
type: string
delete_old_versions:
description: 'Delete old docs versions after deployment'
required: true
default: true
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pages: write
id-token: write
jobs:
build_docs:
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
runs-on: macos-26
env:
DYLD_FALLBACK_LIBRARY_PATH: /opt/homebrew/lib
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
- name: Setup JDK
uses: actions/setup-java@v5
with:
distribution: 'zulu'
java-version: 21
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: '3.14'
- name: Install dependencies
run: |
brew install cairo freetype libffi libjpeg libpng zlib
python3 -m pip install --upgrade pip
python3 -m pip install -r pip-requirements.txt
- uses: gradle/actions/setup-gradle@v6
- name: Build docs
run: ./scripts/build_docs.sh build
- name: Upload docs
uses: actions/upload-artifact@v7
with:
name: docs
retention-days: 1
path: |
docs/
!docs/agents/**
!docs/specs/**
!docs/superpowers/**
deploy_docs:
runs-on: macos-26
needs: build_docs
if: github.event_name == 'workflow_run' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
env:
DYLD_FALLBACK_LIBRARY_PATH: /opt/homebrew/lib
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: '3.14'
- name: Install dependencies
run: |
brew install cairo freetype libffi libjpeg libpng zlib
python3 -m pip install --upgrade pip
python3 -m pip install -r pip-requirements.txt
- name: Get Docs Version
run: cat gradle.properties | grep --color=never VERSION_NAME >> $GITHUB_OUTPUT
id: version
- name: Resolve docs deployment
id: docs
env:
INPUT_DOCS_VERSION: ${{ inputs.version }}
INPUT_DOCS_ALIASES: ${{ inputs.aliases }}
VERSION_NAME: ${{ steps.version.outputs.VERSION_NAME }}
run: |
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
docs_version="$INPUT_DOCS_VERSION"
docs_aliases="$INPUT_DOCS_ALIASES"
elif echo "$VERSION_NAME" | grep --quiet "SNAPSHOT"; then
docs_version="dev"
docs_aliases=""
else
docs_version="$VERSION_NAME"
docs_aliases="latest"
fi
docs_version="$(printf '%s' "$docs_version" | xargs)"
docs_aliases="$(printf '%s' "$docs_aliases" | tr ',' ' ' | xargs)"
if [ -z "$docs_version" ]; then
echo "Docs version must not be blank"
exit 1
fi
case "$docs_version" in
*[!a-zA-Z0-9._-]*)
echo "Docs version contains invalid characters: $docs_version"
exit 1
;;
esac
for docs_alias in $docs_aliases; do
case "$docs_alias" in
*[!a-zA-Z0-9._-]*)
echo "Docs alias contains invalid characters: $docs_alias"
exit 1
;;
esac
done
echo "version=$docs_version" >> "$GITHUB_OUTPUT"
echo "aliases=$docs_aliases" >> "$GITHUB_OUTPUT"
- name: Remove checkout docs directory
run: rm -rf docs
- name: Download docs builds
uses: actions/download-artifact@v8
with:
name: docs
path: docs
- name: Configure git for mike
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git fetch origin gh-pages --depth=1
- name: Deploy docs with mike 🗿
env:
DOCS_ALIASES: ${{ steps.docs.outputs.aliases }}
HAZE_VERSION: ${{ steps.docs.outputs.version }}
run: mike deploy -u --push "$HAZE_VERSION" $DOCS_ALIASES
- name: Delete old doc versions
if: ${{ github.event_name != 'workflow_dispatch' || inputs.delete_old_versions }}
run: |
git fetch origin gh-pages --depth=1
scripts/delete_old_version_docs.sh