@@ -103,8 +103,20 @@ jobs:
103103 run : pip install -r requirements.txt
104104
105105 - name : Build html documentation
106+ env :
107+ SPHINXOPTS : " -W --keep-going"
106108 run : cd ${{ matrix.manual.directory }} && make ${{ matrix.manual.make_target }}
107109
110+ - name : Compute release version
111+ id : release_version
112+ run : |
113+ branch="${GITHUB_REF#refs/heads/}"
114+ if [[ "$branch" == stable* ]]; then
115+ echo "release=${branch#stable}" >> $GITHUB_OUTPUT
116+ else
117+ echo "release=latest" >> $GITHUB_OUTPUT
118+ fi
119+
108120 - name : Compute PDF release version
109121 if : ${{ matrix.manual.build_pdf_path }}
110122 id : pdf_version
@@ -134,14 +146,17 @@ jobs:
134146 name : ${{ matrix.manual.name }}
135147 path : ${{ matrix.manual.directory }}/${{ matrix.manual.build_path }}
136148
137- deploy :
138- name : Deploy pages
149+ # Assembles all artifacts into the gh-pages layout and uploads a single
150+ # "staged" artifact that both `check` and `deploy` consume. Doing the
151+ # assembly once avoids repeating the checkout + merge logic in both jobs.
152+ stage :
153+ name : Stage documentation
139154 needs : build
140155 runs-on : ubuntu-latest
141- if : github.event_name == 'push' # Only deploy on push, not PR
142156
143- permissions :
144- contents : write
157+ outputs :
158+ branch_name : ${{ steps.branch.outputs.branch_name }}
159+ version_name : ${{ steps.branch.outputs.version_name }}
145160
146161 steps :
147162 - name : Cache git metadata
@@ -153,14 +168,14 @@ jobs:
153168 git-metadata-${{ github.sha }}
154169 git-metadata
155170
156- - name : Checkout Github Pages branch
171+ - name : Checkout gh-pages (for redirect sources)
157172 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
158173 with :
159174 ref : gh-pages
160175 fetch-depth : 0
161176 token : ${{ secrets.COMMAND_BOT_PAT }}
162177
163- - name : Download all ${{ needs. build.outputs.branch_name }} artifacts
178+ - name : Download all build artifacts
164179 uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
165180 with :
166181 path : artifacts/
@@ -170,44 +185,33 @@ jobs:
170185 run : |
171186 current_branch="${GITHUB_REF#refs/heads/}"
172187
173- # Find the highest numbered stable branch from the remote
174188 highest_stable=$(git ls-remote --heads origin | sed -n 's?.*refs/heads/stable\([0-9]\{2\}\)$?\1?p' | sort -n | tail -1)
175189 highest_stable_branch="stable${highest_stable}"
176190
177191 echo "Current branch: $current_branch"
178192 echo "Highest stable branch found: $highest_stable_branch"
179193
180- # Map actual branch names to deployment folder names
181194 case "$current_branch" in
182195 "master")
183196 echo "branch_name=latest" >> $GITHUB_OUTPUT
184197 ;;
185198 "$highest_stable_branch")
186199 echo "branch_name=stable" >> $GITHUB_OUTPUT
187- # Also record the numeric version so we can publish to server/<number>/ too
188200 echo "version_name=${highest_stable}" >> $GITHUB_OUTPUT
189201 ;;
190202 *)
191- # Remove stable prefix for current branch
192203 current_branch="${current_branch#stable}"
193204 echo "branch_name=$current_branch" >> $GITHUB_OUTPUT
194205 ;;
195206 esac
196207
197- echo "Deployment folder name: ${{ steps.branch.outputs.branch_name }}"
198- echo "Version name for additional deployment (if applicable): ${{ steps.branch.outputs.version_name }}"
199-
200- - name : Merge ${{ steps.branch.outputs.branch_name }} documentation artifacts into gh-pages
208+ - name : Merge artifacts into gh-pages layout
201209 run : |
202- # List artifacts
203210 ls -la artifacts/*/
204211
205- # Cleanup old documentation
206- rm -rf ${{ steps.branch.outputs.branch_name }}
207212 rm -rf server/${{ steps.branch.outputs.branch_name }}
208213 mkdir -p server/${{ steps.branch.outputs.branch_name }}
209214
210- # Copy all built documentation into dedicated subdirectories
211215 for artifact in artifacts/*; do
212216 if [ -d "$artifact" ]; then
213217 manual_name="$(basename "$artifact")"
@@ -216,48 +220,117 @@ jobs:
216220 fi
217221 done
218222
219- # Move pdf files to the root of the branch_name
220223 mv server/${{ steps.branch.outputs.branch_name }}/*/*.pdf server/${{ steps.branch.outputs.branch_name }}/ || true
221224
222- # If this is the highest stable branch, also deploy to its versioned folder
223225 if [ -n "${{ steps.branch.outputs.version_name }}" ]; then
224- rm -rf server/${{ steps.branch.outputs.version_name }}
225226 cp -r server/${{ steps.branch.outputs.branch_name }} server/${{ steps.branch.outputs.version_name }}
226227 fi
227228
228- # Cleanup
229229 find . -type d -empty -delete
230230 rm -rf artifacts
231231
232232 - name : Add various redirects for go.php and user_manual english version
233233 run : |
234- # Fetch source branches so git checkout origin/... works from the gh-pages checkout
235234 git fetch origin ${{ github.event.repository.default_branch }} ${{ github.ref_name }}
236235
237- # Generate go.php redirect from main branch
238236 git checkout origin/${{ github.event.repository.default_branch }} -- go.php/index.html
239237 mkdir -p server/${{ steps.branch.outputs.branch_name }}/go.php
240238 mv go.php/index.html server/${{ steps.branch.outputs.branch_name }}/go.php/index.html
241239
242- # Generate user_manual english redirect
243240 git checkout origin/${{ github.ref_name }} -- user_manual/index.html
244241 mkdir -p server/${{ steps.branch.outputs.branch_name }}/user_manual
245242 mv user_manual/index.html server/${{ steps.branch.outputs.branch_name }}/user_manual/index.html
246243
247- - name : Commit ${{ steps.branch.outputs.branch_name }} documentation and push to gh-pages
244+ - name : Upload staged site
245+ uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
246+ with :
247+ name : staged-site
248+ path : server/
249+
250+ check :
251+ name : Check staged documentation
252+ needs : stage
253+ runs-on : ubuntu-latest
254+
255+ steps :
256+ - name : Download staged site
257+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
258+ with :
259+ name : staged-site
260+ path : server/
261+
262+ - name : Check for broken links with lychee
263+ uses : lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2.8.0
264+ with :
265+ fail : true
266+ token : ${{ secrets.GITHUB_TOKEN }}
267+ jobSummary : true
268+ args : |
269+ --offline --no-progress --verbose
270+ --remap "https://docs.nextcloud.com/server/${{ needs.stage.outputs.branch_name }} file://$(pwd)/server/${{ needs.stage.outputs.branch_name }}"
271+ 'server/${{ needs.stage.outputs.branch_name }}/**/*.html'
272+
273+
274+ deploy :
275+ name : Deploy documentation to gh-pages
276+ needs : [stage, check]
277+ runs-on : ubuntu-latest
278+ if : github.event_name == 'push'
279+
280+ permissions :
281+ contents : write
282+
283+ steps :
284+ - name : Cache git metadata
285+ uses : actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
286+ with :
287+ path : .git
288+ key : git-metadata-${{ github.sha }}
289+ restore-keys : |
290+ git-metadata-${{ github.sha }}
291+ git-metadata
292+
293+ - name : Checkout gh-pages branch
294+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
295+ with :
296+ ref : gh-pages
297+ fetch-depth : 0
298+ token : ${{ secrets.COMMAND_BOT_PAT }}
299+
300+ - name : Download staged site
301+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
302+ with :
303+ name : staged-site
304+ path : incoming/
305+
306+ - name : Apply staged site to gh-pages working tree
307+ run : |
308+ branch="${{ needs.stage.outputs.branch_name }}"
309+ version="${{ needs.stage.outputs.version_name }}"
310+
311+ rm -rf "server/${branch}"
312+ cp -r "incoming/${branch}" "server/${branch}"
313+
314+ if [ -n "${version}" ]; then
315+ rm -rf "server/${version}"
316+ cp -r "incoming/${version}" "server/${version}"
317+ fi
318+
319+ find . -type d -empty -delete
320+
321+ - name : Commit and push to gh-pages
248322 run : |
249323 git config --local user.email "nextcloud-command@users.noreply.github.com"
250324 git config --local user.name "nextcloud-command"
251325 git add .
252- git diff --staged --quiet || git commit -m "chore: deploy documentation for ${{ steps.branch.outputs.branch_name }}"
253- # Ensure we are up to date with the remote gh-pages branch
326+ git diff --staged --quiet || git commit -m "chore: deploy documentation for ${{ needs.stage.outputs.branch_name }}"
254327 git pull --rebase origin gh-pages || true
255328 git push origin gh-pages || echo "Nothing to push (expected if no changes)"
256329 env :
257330 GH_TOKEN : ${{ secrets.COMMAND_BOT_PAT }}
258331
259332 summary :
260- needs : build
333+ needs : [ build, check]
261334 runs-on : ubuntu-latest
262335 if : always()
263336
@@ -267,6 +340,5 @@ jobs:
267340 name : build-deploy-summary
268341
269342 steps :
270- # Only check if the build was successful
271343 - name : Summary status
272- run : if ${{ needs.build.result != 'success' }}; then exit 1; fi
344+ run : if ${{ needs.build.result != 'success' || needs.check.result != 'success' }}; then exit 1; fi
0 commit comments