Skip to content

Deploy Docs

Deploy Docs #70

Workflow file for this run

name: Deploy Docs
on:
# push:
# branches:
# - master
# - main
workflow_dispatch:
inputs:
version_bump:
description: 'Version bump type (manual only)'
required: false
default: 'patch'
type: choice
options:
- patch
- minor
- major
- none
skip_deploy:
description: 'Skip deployment (manual only)'
required: false
default: false
type: boolean
skip_indexnow:
description: 'Skip IndexNow notification (manual only)'
required: false
default: false
type: boolean
skip_release:
description: 'Skip creating release (manual only)'
required: false
default: false
type: boolean
custom_version:
description: 'Custom version (if bump=none, manual only)'
required: false
type: string
# Cancel in-progress runs when new commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
deploy:
name: 🚀 Deploy to GitHub Pages
runs-on: ubuntu-latest
container:
image: python:3.13
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.skip_deploy != 'true') || (github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip deploy]')) }}
services:
kroki:
image: yuzutech/kroki
env:
KROKI_MERMAID_HOST: mermaid
KROKI_BPMN_HOST: bpmn
KROKI_EXCALIDRAW_HOST: excalidraw
ports:
- 8000:8000
mermaid:
image: yuzutech/kroki-mermaid
bpmn:
image: yuzutech/kroki-bpmn
excalidraw:
image: yuzutech/kroki-excalidraw
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for git-revision-date plugin
token: ${{ secrets.GITHUB_TOKEN }}
sparse-checkout: |
docs
includes
overrides
scripts
kroki_wrapper.py
code_fence_formatter.py
pyproject.toml
mkdocs.yml
- name: 🔐 Mark repository safe for git
shell: bash
run: |
# Allow git operations inside the runner workspace
git config --global --add safe.directory "${{ github.workspace }}"
git config --global --add safe.directory "$(pwd)"
echo "✅ Git safe directories configured"
- name: 👤 Configure git user
shell: bash
run: |
git config --global user.email "78714349+Eatham532@users.noreply.github.com"
git config --global user.name "Eatham532"
echo "✅ Git user configured as Eatham532"
- name: 🔧 Setup Python environment
shell: bash
run: |
set -euo pipefail
python --version
python -m pip install --upgrade pip setuptools wheel build
- name: 📦 Install dependencies
shell: bash
run: |
set -euo pipefail
python -m pip install -e . || python -m pip install .
- name: 🛠️ Install zip utility
shell: bash
run: |
apt-get update && apt-get install -y zip
- name: 📦 Build site for release
env:
KROKI_SERVER_URL: http://kroki:8000
shell: bash
run: |
set -euo pipefail
if ! command -v mkdocs >/dev/null 2>&1; then
echo "❌ ERROR: mkdocs not found on PATH"
exit 1
fi
echo "📦 Building site..."
mkdocs build --clean
echo "✅ Build complete!"
- name: 📦 Create site archive
shell: bash
run: |
cd site
zip -r ../site-build.zip .
cd ..
echo "✅ Site archive created"
- name: 📤 Upload site artifact
uses: actions/upload-artifact@v4
with:
name: site-build
path: site-build.zip
retention-days: 1
- name: 🚀 Deploy to GitHub Pages
env:
KROKI_SERVER_URL: http://kroki:8000
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
set -euo pipefail
echo "🚀 Deploying to GitHub Pages..."
mkdocs gh-deploy --force --clean --remote-name origin
echo "✅ Deployment complete!"
notify-indexnow:
name: 🔔 Notify Search Engines
runs-on: ubuntu-latest
needs: [deploy, create-release] # Only run after deployment and release creation succeed
if: success() && ((github.event_name == 'workflow_dispatch' && github.event.inputs.skip_indexnow != 'true') || (github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip indexnow]')))
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history to compare with gh-pages branch
ref: ${{ github.ref }} # Checkout the branch that triggered the workflow
- name: 🔧 Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: 📦 Install requests library
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install requests
- name: 🔔 Notify IndexNow of changes
shell: bash
run: |
echo "🔔 Notifying search engines of changed pages..."
python scripts/indexnow_notify.py
continue-on-error: true # Don't fail workflow if IndexNow has issues
create-release:
name: 📦 Create GitHub Release
runs-on: ubuntu-latest
needs: deploy # Run after deployment succeeds
if: success() && (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip deploy]')))
permissions:
contents: write
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for release notes
token: ${{ secrets.GITHUB_TOKEN }}
- name: 🔧 Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: 📊 Get current version
if: github.event_name == 'push' || github.event.inputs.skip_release != 'true'
id: get_version
shell: bash
run: |
current_version=$(python scripts/bump_version.py show)
echo "current_version=${current_version}" >> $GITHUB_OUTPUT
echo "📌 Current version: ${current_version}"
- name: 🔼 Determine new version
if: github.event_name == 'push' || github.event.inputs.skip_release != 'true'
id: bump_version
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
# Manual trigger - use configured options
bump_type="${{ github.event.inputs.version_bump }}"
if [ "$bump_type" = "none" ]; then
if [ -n "${{ github.event.inputs.custom_version }}" ]; then
# Custom version - set it
version_change=$(python scripts/bump_version.py set "${{ github.event.inputs.custom_version }}")
new_version=$(echo "$version_change" | cut -d' ' -f3)
echo "📝 Set custom version: ${version_change}"
else
# No bump, no custom - use current version, don't update file
new_version="${{ steps.get_version.outputs.current_version }}"
echo "📌 Using current version (no file update): ${new_version}"
fi
else
# Bump the version
version_change=$(python scripts/bump_version.py "$bump_type")
new_version=$(echo "$version_change" | cut -d' ' -f3)
echo "✅ Version bumped: ${version_change}"
fi
else
# Push trigger - auto bump patch
version_change=$(python scripts/bump_version.py patch)
new_version=$(echo "$version_change" | cut -d' ' -f3)
echo "✅ Auto-bumped patch version: ${version_change}"
fi
echo "new_version=${new_version}" >> $GITHUB_OUTPUT
echo "should_commit=${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && (github.event.inputs.version_bump != 'none' || github.event.inputs.custom_version != '')) }}" >> $GITHUB_OUTPUT
- name: 💾 Commit version bump
if: steps.bump_version.outputs.should_commit == 'true' && (github.event_name == 'push' || github.event.inputs.skip_release != 'true')
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add pyproject.toml
git commit -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }}"
git push origin main
echo "✅ Version committed and pushed"
- name: 📥 Download site artifact
if: github.event_name == 'push' || github.event.inputs.skip_release != 'true'
uses: actions/download-artifact@v4
with:
name: site-build
- name: 📝 Generate release notes
if: github.event_name == 'push' || github.event.inputs.skip_release != 'true'
id: release_notes
shell: bash
run: |
# Get the previous tag (if exists)
previous_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$previous_tag" ]; then
echo "📝 First release - including all commits"
commit_range="HEAD"
else
echo "📝 Generating release notes since ${previous_tag}"
commit_range="${previous_tag}..HEAD"
fi
# Generate commit log (exclude version bump commits)
echo "## 📋 Changes" > release_notes.md
echo "" >> release_notes.md
git log ${commit_range} --pretty=format:"- %s (%h)" --no-merges | grep -v "\[skip deploy\]" | grep -v "^- chore: bump version to" >> release_notes.md || true
echo "" >> release_notes.md
# Get contributors since last tag
if [ -n "$previous_tag" ]; then
contributors=$(git log ${commit_range} --format='%an' | sort -u)
if [ -n "$contributors" ]; then
echo "" >> release_notes.md
echo "## 👥 Contributors" >> release_notes.md
echo "" >> release_notes.md
echo "$contributors" | while read contributor; do
echo "- $contributor" >> release_notes.md
done
fi
fi
echo "✅ Release notes generated"
cat release_notes.md
- name: 🏷️ Create Release
if: github.event_name == 'push' || github.event.inputs.skip_release != 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.bump_version.outputs.new_version }}
name: Release v${{ steps.bump_version.outputs.new_version }}
body_path: release_notes.md
files: |
site-build.zip
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}