Skip to content

Deploy Docs

Deploy Docs #64

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 # Only run after deployment succeeds
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, notify-indexnow] # Run after deployment and notification
if: success() && ((github.event_name == 'workflow_dispatch' && github.event.inputs.skip_release != 'true') || (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
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
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'
shell: bash
run: |
git config user.name "Eatham532"
git config user.email "78714349+Eatham532@users.noreply.github.com"
git add pyproject.toml
git commit -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }} [skip deploy]"
git push origin main
echo "βœ… Version committed and pushed"
- name: πŸ“₯ Download site artifact
uses: actions/download-artifact@v4
with:
name: site-build
- name: πŸ“ Generate release notes
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
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 }}