Skip to content

Commit d7ddf4d

Browse files
authored
ci: add support of versioning documents (#201)
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
1 parent dd746cb commit d7ddf4d

1 file changed

Lines changed: 42 additions & 2 deletions

File tree

.github/workflows/deploy-document.yaml

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,18 @@ name: deploy-document
33
on:
44
push:
55
branches: [main]
6+
tags:
7+
- "v*"
68
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: "Version to deploy (e.g., v1.0.0, latest, dev)"
12+
required: true
13+
default: "latest"
14+
alias:
15+
description: "Version alias (e.g., latest, stable)"
16+
required: false
17+
default: ""
718

819
jobs:
920
deploy-document:
@@ -20,5 +31,34 @@ jobs:
2031
- name: Install the project
2132
run: uv sync --only-dev
2233

23-
- name: Create the document
24-
run: uv run mkdocs gh-deploy --force
34+
- name: Determine version and alias
35+
id: version
36+
run: |
37+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
38+
VERSION="${{ github.event.inputs.version }}"
39+
ALIAS="${{ github.event.inputs.alias }}"
40+
elif [[ "${{ github.ref }}" == refs/tags/v* ]]; then
41+
VERSION="${{ github.ref_name }}"
42+
ALIAS="latest"
43+
else
44+
VERSION="develop"
45+
ALIAS=""
46+
fi
47+
echo "version=$VERSION" >> $GITHUB_OUTPUT
48+
echo "alias=$ALIAS" >> $GITHUB_OUTPUT
49+
echo "Deploying version: $VERSION"
50+
51+
- name: Deploy documentation
52+
run: |
53+
VERSION="${{ steps.version.outputs.version }}"
54+
ALIAS="${{ steps.version.outputs.alias }}"
55+
56+
if [[ -n "$ALIAS" ]]; then
57+
uv run mike deploy --push --update-aliases $VERSION $ALIAS
58+
uv run mike set-default --push $ALIAS
59+
else
60+
uv run mike deploy --push $VERSION
61+
fi
62+
63+
- name: List versions
64+
run: uv run mike list

0 commit comments

Comments
 (0)