-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathaction.yml
More file actions
134 lines (125 loc) · 4.59 KB
/
Copy pathaction.yml
File metadata and controls
134 lines (125 loc) · 4.59 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
name: 'Sphinx to GitHub Pages'
description: 'GitHub Action to deploy Sphinx documentation to GitHub Pages'
author: 'Shengyu Zhang'
branding:
color: 'green'
icon: 'upload-cloud'
inputs:
documentation_path:
description: 'Path to Sphinx source files'
required: false
default: './docs'
requirements_path:
description: 'Path to requirements file, used in `pip install -r XXX` command'
required: false
default: './docs/requirements.txt'
pyproject_extras:
description: 'Extras of Requirement Specifier, used in `pip install .[XXX]` command'
required: false
default: 'docs'
pyproject_group:
description: 'Dependency group (PEP 735) in pyproject.toml to install, used in `pip install --group XXX` command. Requires pip >= 25.1 (installed automatically when this input is set).'
required: false
default: ''
python_version:
description: 'Version of Python'
required: false
default: '3.12'
sphinx_version:
description: 'Version of Sphinx'
required: false
default: ''
cache:
description: 'Enable cache to speed up documentation building'
required: false
default: false
sphinx_build_options:
description: 'Additional options passed to sphinx-build'
required: false
default: ''
checkout:
description: 'Whether to automatically checkout the repository, if false, user need to do it byself'
required: false
default: true
publish:
description: 'Whether to automatically publish the pages, if false, user need to manually publish by self'
required: false
default: true
outputs:
page_url:
description: 'URL to deployed GitHub Pages, only available when option publish is set to true'
value: ${{ steps.deployment.outputs.page_url }}
artifact:
description: 'Directory where artifact (HTML documentation) is stored, user can use it to deploy GitHub Pages manually'
value: ${{ steps.build.outputs.artifact }}
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v6
if: ${{ inputs.checkout == 'true' && inputs.cache == 'true' }}
with:
fetch-depth: 0 # Required by sphinxnotes-incrbuild
- name: Checkout
uses: actions/checkout@v6
if: ${{ inputs.checkout == 'true' && inputs.cache == 'false' }}
- name: Setup python
uses: actions/setup-python@v6
if: ${{ inputs.cache == 'true' }}
with:
python-version: ${{ inputs.python_version }}
cache: 'pip'
- name: Setup python
uses: actions/setup-python@v6
if: ${{ inputs.cache == 'false' }}
with:
python-version: ${{ inputs.python_version }}
- name: Restore cache
uses: actions/cache@v5
if: ${{ inputs.cache == 'true' }}
with:
path: /tmp/sphinxnotes-incrbuild
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key: sphinxnotes-pages-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
sphinxnotes-pages-${{ runner.os }}
- name: Enable github problem matcher
uses: sphinx-doc/github-problem-matcher@master
- id: build
name: Build documentation
run: ${{ github.action_path }}/main.sh
shell: bash
env:
# See https://github.com/actions/runner/issues/665
INPUT_DOCUMENTATION_PATH: ${{ inputs.documentation_path }}
INPUT_REQUIREMENTS_PATH: ${{ inputs.requirements_path }}
INPUT_PYPROJECT_EXTRAS: ${{ inputs.pyproject_extras }}
INPUT_PYPROJECT_GROUP: ${{ inputs.pyproject_group }}
INPUT_SPHINX_VERSION: ${{ inputs.sphinx_version }}
INPUT_CACHE: ${{ inputs.cache }}
INPUT_SPHINX_BUILD_OPTIONS: ${{ inputs.sphinx_build_options }}
- name: Setup Pages
uses: actions/configure-pages@v6
if: ${{ inputs.publish == 'true' }}
- name: Fix file permissions
shell: sh
if: runner.os == 'Linux'
# https://github.com/actions/deploy-pages/issues/188
run: |
chmod -c -R +rX "$INPUT_PATH" |
while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
env:
INPUT_PATH: ${{ steps.build.outputs.artifact }}
- name: Upload artifact
# https://github.com/actions/upload-pages-artifact/issues/142
uses: actions/upload-pages-artifact@v5.0.0
if: ${{ inputs.publish == 'true' }}
with:
path: ${{ steps.build.outputs.artifact }}
- id: deployment
name: Deploy to GitHub Pages
uses: actions/deploy-pages@v5
if: ${{ inputs.publish == 'true' }}