-
Notifications
You must be signed in to change notification settings - Fork 1
72 lines (62 loc) · 2.15 KB
/
docs.yml
File metadata and controls
72 lines (62 loc) · 2.15 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
name: Docs
on:
push:
tags:
- 'docs/*'
workflow_dispatch:
permissions:
contents: write
jobs:
deploy-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install docs dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements-docs.txt ]; then pip install -r requirements-docs.txt; fi
- name: Preflight check (mkdocs.yml has mike plugin)
run: |
if ! grep -q '^ *- *mike *$' mkdocs.yml && ! grep -q 'plugins:.*mike' mkdocs.yml; then
echo "::error::Plugin 'mike' is not enabled in mkdocs.yml (add under plugins: - mike)"
exit 1
fi
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Determine version label
id: ver
env:
INPUT_VERSION: ${{ github.event.inputs.version }}
run: |
if [ -n "$INPUT_VERSION" ]; then
VERSION="$INPUT_VERSION"
else
# Например, docs/v1.0.0 -> v1.0.0
VERSION="${GITHUB_REF_NAME#docs/}"
fi
echo "Using version: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Deploy docs with mike (update latest alias)
if: ${{ github.event.inputs.alias_latest != 'false' }}
env:
VERSION: ${{ steps.ver.outputs.version }}
run: |
mike deploy --push --branch gh-pages --update-aliases "$VERSION" latest
mike set-default --push --branch gh-pages latest
- name: Deploy docs with mike (no alias update)
if: ${{ github.event.inputs.alias_latest == 'false' }}
env:
VERSION: ${{ steps.ver.outputs.version }}
run: |
mike deploy --push --branch gh-pages "$VERSION"