-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
108 lines (100 loc) · 3.62 KB
/
action.yml
File metadata and controls
108 lines (100 loc) · 3.62 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
97
98
99
100
101
102
103
104
105
106
107
108
name: Build and Deploy MkDocs Material (Reloaded)
description: Builds and/or Deploys MkDocs Material to GitHub Pages, or a Directory
branding:
icon: "book"
color: "red"
inputs:
mkdocs-version:
required: false
default: "latest"
description: "MkDocs version to use"
requirements:
required: false
default: "./docs/requirements.txt"
description: "Path to the requirements.txt file"
config-file:
required: false
default: "mkdocs.yml"
description: "Path to the mkdocs.yml file"
publish-to-pages:
required: false
default: "true"
description: "Whether to publish to GitHub Pages"
checkout-current-repo:
required: false
default: "true"
description: "Whether to perform repository checkout"
pre-build-command:
required: false
description: "Path to the pre-build command"
pre-build-command-shell:
required: false
default: "bash"
description: "Shell to use for running the pre-build command"
output-directory:
required: false
default: "./site"
description: "Custom output directory for the MkDocs build"
runs:
using: "composite"
steps:
- name: Checkout Repository
if: ${{ inputs.checkout-current-repo == 'true' }}
uses: actions/checkout@v6
with:
submodules: "recursive"
- name: Setup Pages
if: ${{ inputs.publish-to-pages == 'true' }}
id: pages
uses: actions/configure-pages@v6
- name: Install MkDocs and Dependencies
shell: bash
run: |
python -m pip install --upgrade pip
# If requirements.txt exists and contains mkdocs-material, install only from requirements
# (user has locked their mkdocs version). Otherwise, install mkdocs-material from
# mkdocs-version input alongside requirements to let pip resolve compatible versions.
if [ -f "${{ inputs.requirements }}" ]; then
if grep -q "mkdocs-material" "${{ inputs.requirements }}"; then
pip install -r "${{ inputs.requirements }}"
else
if [ "${{ inputs.mkdocs-version }}" = "latest" ]; then
pip install mkdocs-material -r "${{ inputs.requirements }}"
else
pip install mkdocs-material==${{ inputs.mkdocs-version }} -r "${{ inputs.requirements }}"
fi
fi
else
if [ "${{ inputs.mkdocs-version }}" = "latest" ]; then
pip install mkdocs-material
else
pip install mkdocs-material==${{ inputs.mkdocs-version }}
fi
fi
- name: Run Pre-build Command
if: ${{ inputs.pre-build-command }}
shell: ${{ inputs.pre-build-command-shell }}
run: ${{ inputs.pre-build-command }}
- name: Build MkDocs Site
shell: bash
run: |
# Build to temp location (mkdocs interprets --site-dir relative to config file)
CONFIG_DIR=$(dirname "${{ inputs.config-file }}")
TEMP_DIR="${CONFIG_DIR}/.mkdocs-build-temp"
rm -rf "$TEMP_DIR"
mkdocs build --config-file "${{ inputs.config-file }}" --site-dir ".mkdocs-build-temp"
# Move to user's desired output directory (relative to workspace root)
rm -rf "${{ inputs.output-directory }}"
mv "$TEMP_DIR" "${{ inputs.output-directory }}"
- name: Upload pages artifact
if: ${{ inputs.publish-to-pages == 'true' }}
uses: actions/upload-pages-artifact@v4
with:
name: "github-pages"
path: "${{ inputs.output-directory }}"
- name: Deploy to GitHub Pages
if: ${{ inputs.publish-to-pages == 'true' }}
id: deployment
uses: actions/deploy-pages@v5
with:
artifact_name: "github-pages"