-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (85 loc) · 3.83 KB
/
_docs.yml
File metadata and controls
96 lines (85 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# ─────────────────────────────────────────────────────────────────────────────
# _docs.yml — Reusable Documentation Builder & Deployer
#
# Builds static documentation using MkDocs and Mike for versioning, and
# deploys it to GitHub Pages.
#
# Inputs:
# build_type (required): "dev-branch", "dev", "nightly", "release", or "post"
# alias (required): The alias to use for the deployment (e.g., "latest", "nightly")
#
# Outputs:
# deployed_url — The URL/path where the docs were deployed
#
# Callers: development.yml, nightly.yml, release.yml
# ─────────────────────────────────────────────────────────────────────────────
name: "Docs Builder & Deployer (Reusable)"
on:
workflow_call:
inputs:
build_type:
description: "Deploy target type: dev-branch, dev, nightly, release, or post"
required: true
type: string
alias:
description: "The alias to use for the documentation version (e.g., latest, nightly)"
required: true
type: string
outputs:
deployed_url:
description: "Path where the docs were deployed"
value: ${{ jobs.build-and-deploy-docs.outputs.deployed_url }}
permissions:
contents: write # Push to gh-pages branch
jobs:
build-and-deploy-docs:
name: "Build & Deploy Docs (${{ inputs.build_type }})"
runs-on: ubuntu-latest
outputs:
deployed_url: ${{ steps.dest.outputs.path }}
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.x"
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
- name: Install MkDocs and dependencies
run: |
# Install standard mkdocs, material theme, and mike for versioning
pip install mkdocs-material mike
# Install any other requirements if they exist
if [ -f docs/requirements.txt ]; then pip install -r docs/requirements.txt; fi
- name: Compute deployment destination path
id: dest
run: |
case "${{ inputs.build_type }}" in
dev-branch) echo "path=pr-${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT" ;;
dev) echo "path=dev" >> "$GITHUB_OUTPUT" ;;
nightly) echo "path=nightly" >> "$GITHUB_OUTPUT" ;;
release) echo "path=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" ;;
post) echo "path=post" >> "$GITHUB_OUTPUT" ;;
*) echo "path=${{ inputs.alias }}" >> "$GITHUB_OUTPUT" ;;
esac
- name: Build and deploy using Mike
run: |
VERSION_PATH="${{ steps.dest.outputs.path }}"
ALIAS="${{ inputs.alias }}"
# Use mike to deploy to gh-pages branch
# --push: push to origin
# --update-aliases: update the alias pointer
if [ "$ALIAS" != "" ] && [ "$ALIAS" != "$VERSION_PATH" ]; then
mike deploy --push --update-aliases $VERSION_PATH $ALIAS
else
mike deploy --push $VERSION_PATH
fi
# If release, also set it as default
if [ "${{ inputs.build_type }}" == "release" ]; then
mike set-default --push $ALIAS
fi