@@ -11,86 +11,242 @@ permissions:
1111 contents : read
1212
1313jobs :
14- user_manual :
14+ build :
15+
16+ name : Build ${{ matrix.manual.name }}
1517 runs-on : ubuntu-latest
18+
19+ strategy :
20+ matrix :
21+ manual :
22+ - name : " user_manual"
23+ directory : " user_manual"
24+ make_target : " html"
25+ build_path : " _build/html"
26+ build_pdf_path : " _build/latex"
27+ publish : true
28+
29+ - name : " user_manual-en"
30+ directory : " user_manual"
31+ make_target : " html-lang-en"
32+ build_path : " _build/html"
33+ publish : false
34+
35+ - name : " developer_manual"
36+ directory : " developer_manual"
37+ make_target : " html"
38+ build_path : " _build/html/com"
39+ publish : true
40+
41+ - name : " admin_manual"
42+ directory : " admin_manual"
43+ make_target : " html"
44+ build_path : " _build/html/com"
45+ build_pdf_path : " _build/latex"
46+ publish : true
47+
1648 steps :
17- - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
49+ - name : Cache git metadata
50+ uses : actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
1851 with :
19- persist-credentials : false
20- - uses : actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6
52+ path : .git
53+ key : git-metadata-${{ github.sha }}
54+ restore-keys : |
55+ git-metadata-${{ github.sha }}
56+ git-metadata
57+
58+ - name : Checkout repository
59+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
60+
61+ - name : Install LaTeX dependencies
62+ if : ${{ matrix.manual.build_pdf_path }}
63+ run : |
64+ sudo DEBIAN_FRONTEND=noninteractive apt-get update
65+ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
66+ python3-pil \
67+ python3-pip \
68+ texlive-fonts-recommended \
69+ latexmk \
70+ texlive-latex-extra \
71+ texlive-latex-recommended \
72+ texlive-xetex \
73+ texlive-fonts-extra-links \
74+ texlive-fonts-extra \
75+ xindy
76+
77+ - uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2178 with :
2279 python-version : ' 3.12'
2380 cache : ' pip'
81+
2482 - name : Install pip dependencies
2583 run : pip install -r requirements.txt
26- - name : Build using Makefile
27- run : cd user_manual && make html
28- - name : Pack the results in local tar file
29- shell : bash
30- run : tar czf /tmp/documentation.tar.gz -C user_manual/_build/html .
84+
85+ - name : Build html documentation
86+ run : cd ${{ matrix.manual.directory }} && make ${{ matrix.manual.make_target }}
87+
88+ - name : Compute PDF release version
89+ if : ${{ matrix.manual.build_pdf_path }}
90+ id : pdf_version
91+ run : |
92+ branch="${GITHUB_REF#refs/heads/}"
93+ if [[ "$branch" == stable* ]]; then
94+ echo "release=${branch#stable}" >> $GITHUB_OUTPUT
95+ else
96+ echo "release=latest" >> $GITHUB_OUTPUT
97+ fi
98+
99+ - name : Build pdf documentation
100+ if : ${{ matrix.manual.build_pdf_path }}
101+ env :
102+ DOCS_RELEASE : ${{ steps.pdf_version.outputs.release }}
103+ run : |
104+ set -e
105+ cd ${{ matrix.manual.directory }}
106+ make latexpdf
107+ ls -la ${{ matrix.manual.build_pdf_path }}
108+ cp ${{ matrix.manual.build_pdf_path }}/*.pdf ${{ matrix.manual.build_path }}/
109+
31110 - name : Upload static documentation
32- uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
111+ uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
112+ if : ${{ matrix.manual.publish }}
33113 with :
34- name : User manual.zip
35- path : " /tmp/documentation.tar.gz "
114+ name : ${{ matrix. manual.name }}
115+ path : ${{ matrix.manual.directory }}/${{ matrix.manual.build_path }}
36116
37- user_manual-en :
117+ deploy :
118+ name : Deploy pages
119+ needs : build
38120 runs-on : ubuntu-latest
39- steps :
40- - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
41- with :
42- persist-credentials : false
43- - uses : actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6
44- with :
45- python-version : ' 3.12'
46- cache : ' pip'
47- - name : Install pip dependencies
48- run : pip install -r requirements.txt
49- - name : Build using Makefile
50- run : cd user_manual && make html-lang-en
121+ if : github.event_name == 'push' # Only deploy on push, not PR
122+
123+ permissions :
124+ contents : write
51125
52- developer_manual :
53- runs-on : ubuntu-latest
54126 steps :
55- - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
127+ - name : Cache git metadata
128+ uses : actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
56129 with :
57- persist-credentials : false
58- - uses : actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6
130+ path : .git
131+ key : git-metadata-${{ github.sha }}
132+ restore-keys : |
133+ git-metadata-${{ github.sha }}
134+ git-metadata
135+
136+ - name : Checkout Github Pages branch
137+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
59138 with :
60- python-version : ' 3.12'
61- cache : ' pip'
62- - name : Install pip dependencies
63- run : pip install -r requirements.txt
64- - name : Build using Makefile
65- run : cd developer_manual && make html
66- - name : Pack the results in local tar file
67- shell : bash
68- run : tar czf /tmp/documentation.tar.gz -C developer_manual/_build/html/com .
69- - name : Upload static documentation
70- uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
139+ ref : gh-pages
140+ fetch-depth : 0
141+ token : ${{ secrets.COMMAND_BOT_PAT }}
142+
143+ - name : Download all ${{ needs.build.outputs.branch_name }} artifacts
144+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
71145 with :
72- name : Developer manual.zip
73- path : " /tmp/documentation.tar.gz"
146+ path : artifacts/
147+
148+ - name : Get branch name and find latest stable
149+ id : branch
150+ run : |
151+ current_branch="${GITHUB_REF#refs/heads/}"
152+
153+ # Find the highest numbered stable branch from the remote
154+ highest_stable=$(git ls-remote --heads origin | sed -n 's?.*refs/heads/stable\([0-9]\{2\}\)$?\1?p' | sort -n | tail -1)
155+ highest_stable_branch="stable${highest_stable}"
156+
157+ echo "Current branch: $current_branch"
158+ echo "Highest stable branch found: $highest_stable_branch"
159+
160+ # Map actual branch names to deployment folder names
161+ case "$current_branch" in
162+ "master")
163+ echo "branch_name=latest" >> $GITHUB_OUTPUT
164+ ;;
165+ "$highest_stable_branch")
166+ echo "branch_name=stable" >> $GITHUB_OUTPUT
167+ # Also record the numeric version so we can publish to server/<number>/ too
168+ echo "version_name=${highest_stable}" >> $GITHUB_OUTPUT
169+ ;;
170+ *)
171+ # Remove stable prefix for current branch
172+ current_branch="${current_branch#stable}"
173+ echo "branch_name=$current_branch" >> $GITHUB_OUTPUT
174+ ;;
175+ esac
176+
177+ echo "Deployment folder name: ${{ steps.branch.outputs.branch_name }}"
178+ echo "Version name for additional deployment (if applicable): ${{ steps.branch.outputs.version_name }}"
179+
180+ - name : Merge ${{ steps.branch.outputs.branch_name }} documentation artifacts into gh-pages
181+ run : |
182+ # List artifacts
183+ ls -la artifacts/*/
184+
185+ # Cleanup old documentation
186+ rm -rf ${{ steps.branch.outputs.branch_name }}
187+ rm -rf server/${{ steps.branch.outputs.branch_name }}
188+ mkdir -p server/${{ steps.branch.outputs.branch_name }}
189+
190+ # Copy all built documentation into dedicated subdirectories
191+ for artifact in artifacts/*; do
192+ if [ -d "$artifact" ]; then
193+ manual_name="$(basename "$artifact")"
194+ mkdir -p "server/${{ steps.branch.outputs.branch_name }}/$manual_name"
195+ cp -r "$artifact/"* "server/${{ steps.branch.outputs.branch_name }}/$manual_name/"
196+ fi
197+ done
198+
199+ # Move pdf files to the root of the branch_name
200+ mv server/${{ steps.branch.outputs.branch_name }}/*/*.pdf server/${{ steps.branch.outputs.branch_name }}/ || true
201+
202+ # If this is the highest stable branch, also deploy to its versioned folder
203+ if [ -n "${{ steps.branch.outputs.version_name }}" ]; then
204+ rm -rf server/${{ steps.branch.outputs.version_name }}
205+ cp -r server/${{ steps.branch.outputs.branch_name }} server/${{ steps.branch.outputs.version_name }}
206+ fi
207+
208+ # Cleanup
209+ find . -type d -empty -delete
210+ rm -rf artifacts
211+
212+ - name : Add various redirects for go.php and user_manual english version
213+ run : |
214+ # Fetch source branches so git checkout origin/... works from the gh-pages checkout
215+ git fetch origin ${{ github.event.repository.default_branch }} ${{ github.ref_name }}
74216
75- admin_manual :
217+ # Generate go.php redirect from main branch
218+ git checkout origin/${{ github.event.repository.default_branch }} -- go.php/index.html
219+ mkdir -p server/${{ steps.branch.outputs.branch_name }}/go.php
220+ mv go.php/index.html server/${{ steps.branch.outputs.branch_name }}/go.php/index.html
221+
222+ # Generate user_manual english redirect
223+ git checkout origin/${{ github.ref_name }} -- user_manual/index.html
224+ mkdir -p server/${{ steps.branch.outputs.branch_name }}/user_manual
225+ mv user_manual/index.html server/${{ steps.branch.outputs.branch_name }}/user_manual/index.html
226+
227+ - name : Commit ${{ steps.branch.outputs.branch_name }} documentation and push to gh-pages
228+ run : |
229+ git config --local user.email "nextcloud-command@users.noreply.github.com"
230+ git config --local user.name "nextcloud-command"
231+ git add .
232+ git diff --staged --quiet || git commit -m "chore: deploy documentation for ${{ steps.branch.outputs.branch_name }}"
233+ # Ensure we are up to date with the remote gh-pages branch
234+ git pull --rebase origin gh-pages || true
235+ git push origin gh-pages || echo "Nothing to push (expected if no changes)"
236+ env :
237+ GH_TOKEN : ${{ secrets.COMMAND_BOT_PAT }}
238+
239+ summary :
240+ needs : build
76241 runs-on : ubuntu-latest
242+ if : always()
243+
244+ permissions :
245+ contents : read
246+
247+ name : build-deploy-summary
248+
77249 steps :
78- - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
79- with :
80- persist-credentials : false
81- - uses : actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6
82- with :
83- python-version : ' 3.12'
84- cache : ' pip'
85- - name : Install pip dependencies
86- run : pip install -r requirements.txt
87- - name : Build using Makefile
88- run : cd admin_manual && make html
89- - name : Pack the results in local tar file
90- shell : bash
91- run : tar czf /tmp/documentation.tar.gz -C admin_manual/_build/html/com .
92- - name : Upload static documentation
93- uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
94- with :
95- name : Administration manual.zip
96- path : " /tmp/documentation.tar.gz"
250+ # Only check if the build was successful
251+ - name : Summary status
252+ run : if ${{ needs.build.result != 'success' }}; then exit 1; fi
0 commit comments