-
Notifications
You must be signed in to change notification settings - Fork 3
178 lines (157 loc) Β· 7.61 KB
/
docs.yaml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Build & publish docs
on:
push:
branches:
- master
repository_dispatch:
types: [docs]
workflow_dispatch:
jobs:
build:
name: Build docs
runs-on: ubuntu-latest
strategy:
matrix:
# you must not use anything but include here or the version.json generation will fail!
include:
- version: "1.10.2"
source: "tags"
python: "3.7"
sphinx: "4.5.0"
mermaid: "0.7.1"
jinja: "3.1.1"
mermaid_fix: "true"
- version: "master"
source: "heads"
python: "3.7"
sphinx: "4.5.0"
mermaid: "0.7.1"
jinja: "3.1.1"
mermaid_fix: "true"
- version: "maintenance"
source: "heads"
python: "3.7"
sphinx: "4.5.0"
mermaid: "0.7.1"
jinja: "3.1.1"
mermaid_fix: "true"
- version: "devel"
source: "heads"
python: "3.7"
sphinx: "4.5.0"
mermaid: "0.7.1"
jinja: "3.1.1"
mermaid_fix: "true"
steps:
- name: π§Ύ Log event & matrix
run: |
echo "Event: ${{ github.event_name }} - ${{ toJson(github.event.client_payload) }}"
echo "Matrix: ${{ matrix.version }}, ${{ matrix.source }}, ${{ matrix.python }}, ${{ matrix.mermaid }}, ${{ matrix.mermaid_fix }}"
echo "Formatted ref: ${{ format('refs/{0}/{1}', matrix.source, matrix.version) }}"
- name: β¬ Checkout docs.octoprint.org
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
uses: actions/checkout@v4
with:
path: docs.octoprint.org
- name: π Determine latest OctoPrint release
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
run: |
OCTOPRINT_VERSION=$(curl -i https://github.com/OctoPrint/OctoPrint/releases/latest | grep -i location: | head -n1 | awk -F/ '{print $NF}' | tr -d '\r')
echo "OCTOPRINT_VERSION=$OCTOPRINT_VERSION" >> $GITHUB_ENV
- name: π Set up Python ${{ matrix.python }}
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: π Preinstall some dependencies
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
run: |
pip install sphinx==${{ matrix.sphinx }} sphinxcontrib-mermaid==${{ matrix.mermaid }} Jinja2==${{ matrix.jinja }}
- name: π Set up NodeJS
if: matrix.mermaid_fix == 'true' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version))
uses: actions/setup-node@v3
with:
node-version: "16"
- name: π Install mermaid-cli
if: matrix.mermaid_fix == 'true' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version))
run: |
npm install @mermaid-js/mermaid-cli
- name: β¬ Checkout OctoPrint
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
uses: actions/checkout@v4
with:
repository: "OctoPrint/OctoPrint"
ref: ${{ matrix.version }}
path: OctoPrint
- name: π Install OctoPrint
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
run: |
cd ${{ github.workspace }}/OctoPrint
pip install .[develop,docs]
- name: π Generate versions.json
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
run: |
python ${{ github.workspace }}/docs.octoprint.org/util/versions_from_matrix.py ${{ github.workspace }}/docs.octoprint.org/.github/workflows/docs.yaml versions.json
- name: π Build docs
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
run: |
cd ${{ github.workspace }}/docs.octoprint.org/util/versionselector
if [[ "${{ matrix.mermaid_fix }}" == "true" ]]; then
python versionselector.py ${{ github.workspace }}/OctoPrint/docs/ ${{ matrix.version }} ${{ env.OCTOPRINT_VERSION }} ${{ github.workspace }}/versions.json -D mermaid_cmd=${{ github.workspace }}/node_modules/.bin/mmdc -D mermaid_output_format=svg -D mermaid_version=
echo ".rst-content object[type^='image/']{width: 100%;}" >> ${{ github.workspace }}/OctoPrint/docs/_build/html/${{ matrix.version }}/_static/theme_overrides.css
else
python versionselector.py ${{ github.workspace }}/OctoPrint/docs/ ${{ matrix.version }} ${{ env.OCTOPRINT_VERSION }} ${{ github.workspace }}/versions.json
fi
#- name: π Run link check
# id: lc
# uses: peter-evans/link-checker@v1
# with:
# args: -v -r -d ./OctoPrint/docs/_build/html/${{ matrix.version }} ./OctoPrint/docs/_build/html/${{ matrix.version }}
#- name: π Evaluate link check
# run: exit ${{ steps.lc.outputs.exit_code }}
- name: β¬ Persist build result
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.client_payload.ref == format('refs/{0}/{1}', matrix.source, matrix.version)
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.version }}
path: ${{ github.workspace }}/OctoPrint/docs/_build/html/${{ matrix.version }}
deploy:
name: Deploy docs
needs: build
runs-on: ubuntu-latest
steps:
- name: β¬ Checkout docs.octoprint.org
uses: actions/checkout@v4
with:
ref: gh-pages
path: docs
- name: β¬ Fetch all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: π§Ή Cleanup all docs
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: |
count=`ls -1 artifacts | wc -l`
if [ $count != '0' ]; then
rm -rf docs/* || true
touch docs/.nojekyll
cp -rv artifacts/* docs
fi
- name: π§Ή Cleanup regenerated docs
if: github.event_name == 'repository_dispatch'
run: |
version="${{ github.event.client_payload.ref }}"
version=${version#"refs/heads/"}
version=${version#"refs/tags/"}
echo "Version is $version"
if [ -d "artifacts/$version" ]; then
rm -rf docs/$version || true
cp -r artifacts/$version docs/
fi
- name: π Commit & deploy
uses: EndBug/add-and-commit@v9
with:
cwd: "docs"
message: "Publish new build of docs"
default_author: github_actions