Skip to content

Commit 0b645ad

Browse files
committed
fixup! fixup! feat(ci): add lychee broken link test
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent 8cc5847 commit 0b645ad

File tree

1 file changed

+92
-96
lines changed

1 file changed

+92
-96
lines changed

.github/workflows/sphinxbuild.yml

Lines changed: 92 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ jobs:
4444
sudo chown -R $(id -u):$(id -g) /tmp/apt/cache/archives
4545
4646
build:
47-
4847
name: Build ${{ matrix.manual.name }}
4948
runs-on: ubuntu-latest
5049
needs: setup-latex-cache
@@ -170,98 +169,96 @@ jobs:
170169
version_name: ${{ steps.branch.outputs.version_name }}
171170

172171
steps:
173-
- name: Cache git metadata
174-
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
175-
with:
176-
path: .git
177-
key: git-metadata-${{ github.sha }}
178-
restore-keys: |
179-
git-metadata-${{ github.sha }}
180-
git-metadata
172+
- name: Download all artifacts
173+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
174+
with:
175+
path: artifacts/
176+
177+
- name: Get branch name and find latest stable
178+
id: branch
179+
run: |
180+
current_branch="${GITHUB_REF#refs/heads/}"
181+
182+
# Find the highest numbered stable branch from the remote
183+
highest_stable=$(git ls-remote --heads origin | sed -n 's?.*refs/heads/stable\([0-9]\{2\}\)$?\1?p' | sort -n | tail -1)
184+
highest_stable_branch="stable${highest_stable}"
185+
186+
echo "Current branch: $current_branch"
187+
echo "Highest stable branch found: $highest_stable_branch"
188+
189+
# Map actual branch names to deployment folder names
190+
case "$current_branch" in
191+
"master")
192+
echo "branch_name=latest" >> $GITHUB_OUTPUT
193+
;;
194+
"$highest_stable_branch")
195+
echo "branch_name=stable" >> $GITHUB_OUTPUT
196+
# Also record the numeric version so we can publish to server/<number>/ too
197+
echo "version_name=${highest_stable}" >> $GITHUB_OUTPUT
198+
;;
199+
*)
200+
# Remove stable prefix for current branch
201+
current_branch="${current_branch#stable}"
202+
echo "branch_name=$current_branch" >> $GITHUB_OUTPUT
203+
;;
204+
esac
205+
206+
echo "Deployment folder name: ${{ steps.branch.outputs.branch_name }}"
207+
echo "Version name for additional deployment (if applicable): ${{ steps.branch.outputs.version_name }}"
208+
209+
- name: Merge ${{ steps.branch.outputs.branch_name }} documentation artifacts into gh-pages
210+
run: |
211+
# List artifacts
212+
ls -la artifacts/*/
213+
214+
# Cleanup old documentation
215+
rm -rf ${{ steps.branch.outputs.branch_name }}
216+
rm -rf server/${{ steps.branch.outputs.branch_name }}
217+
mkdir -p server/${{ steps.branch.outputs.branch_name }}
218+
219+
# Copy all built documentation into dedicated subdirectories
220+
for artifact in artifacts/*; do
221+
if [ -d "$artifact" ]; then
222+
manual_name="$(basename "$artifact")"
223+
mkdir -p "server/${{ steps.branch.outputs.branch_name }}/$manual_name"
224+
cp -r "$artifact/"* "server/${{ steps.branch.outputs.branch_name }}/$manual_name/"
225+
fi
226+
done
227+
228+
# Move pdf files to the root of the branch_name
229+
mv server/${{ steps.branch.outputs.branch_name }}/*/*.pdf server/${{ steps.branch.outputs.branch_name }}/ || true
230+
231+
# If this is the highest stable branch, also deploy to its versioned folder
232+
if [ -n "${{ steps.branch.outputs.version_name }}" ]; then
233+
rm -rf server/${{ steps.branch.outputs.version_name }}
234+
cp -r server/${{ steps.branch.outputs.branch_name }} server/${{ steps.branch.outputs.version_name }}
235+
fi
236+
237+
# Cleanup
238+
find . -type d -empty -delete
239+
rm -rf artifacts
240+
241+
- name: Add various redirects for go.php and user_manual english version
242+
run: |
243+
# Fetch source branches so git checkout origin/... works from the gh-pages checkout
244+
git fetch origin ${{ github.event.repository.default_branch }} ${{ github.ref_name }}
245+
246+
# Generate go.php redirect from main branch
247+
git checkout origin/${{ github.event.repository.default_branch }} -- go.php/index.html
248+
mkdir -p server/${{ steps.branch.outputs.branch_name }}/go.php
249+
mv go.php/index.html server/${{ steps.branch.outputs.branch_name }}/go.php/index.html
250+
251+
# Generate user_manual english redirect
252+
git checkout origin/${{ github.ref_name }} -- user_manual/index.html
253+
mkdir -p server/${{ steps.branch.outputs.branch_name }}/user_manual
254+
mv user_manual/index.html server/${{ steps.branch.outputs.branch_name }}/user_manual/index.html
255+
256+
- name: Upload staged site
257+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
258+
with:
259+
name: staged-site
260+
path: server/
181261

182-
- name: Checkout gh-pages (for redirect sources)
183-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
184-
with:
185-
ref: gh-pages
186-
fetch-depth: 0
187-
token: ${{ secrets.COMMAND_BOT_PAT }}
188-
189-
- name: Download all ${{ needs.build.outputs.branch_name }} artifacts
190-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
191-
with:
192-
path: artifacts/
193-
194-
- name: Get branch name and find latest stable
195-
id: branch
196-
run: |
197-
current_branch="${GITHUB_REF#refs/heads/}"
198-
199-
# Find the highest numbered stable branch from the remote
200-
highest_stable=$(git ls-remote --heads origin | sed -n 's?.*refs/heads/stable\([0-9]\{2\}\)$?\1?p' | sort -n | tail -1)
201-
highest_stable_branch="stable${highest_stable}"
202-
203-
echo "Current branch: $current_branch"
204-
echo "Highest stable branch found: $highest_stable_branch"
205-
206-
# Map actual branch names to deployment folder names
207-
case "$current_branch" in
208-
"master")
209-
echo "branch_name=latest" >> $GITHUB_OUTPUT
210-
;;
211-
"$highest_stable_branch")
212-
echo "branch_name=stable" >> $GITHUB_OUTPUT
213-
# Also record the numeric version so we can publish to server/<number>/ too
214-
echo "version_name=${highest_stable}" >> $GITHUB_OUTPUT
215-
;;
216-
*)
217-
# Remove stable prefix for current branch
218-
current_branch="${current_branch#stable}"
219-
echo "branch_name=$current_branch" >> $GITHUB_OUTPUT
220-
;;
221-
esac
222-
223-
echo "Deployment folder name: ${{ steps.branch.outputs.branch_name }}"
224-
echo "Version name for additional deployment (if applicable): ${{ steps.branch.outputs.version_name }}"
225-
226-
- name: Merge ${{ steps.branch.outputs.branch_name }} documentation artifacts into gh-pages
227-
run: |
228-
# Remove old documentation for this branch
229-
rm -rf server/${{ steps.branch.outputs.branch_name }}
230-
mkdir -p server/${{ steps.branch.outputs.branch_name }}
231-
232-
# Move each manual's HTML output into the branch directory structure
233-
mv artifacts/user_manual/* server/${{ steps.branch.outputs.branch_name }}/ || true
234-
mv artifacts/admin_manual/* server/${{ steps.branch.outputs.branch_name }}/ || true
235-
mv artifacts/developer_manual/* server/${{ steps.branch.outputs.branch_name }}/com/ || true
236-
237-
# If this is the highest stable branch, also deploy to versioned folder (e.g., server/28/)
238-
if [ -n "${{ steps.branch.outputs.version_name }}" ]; then
239-
rm -rf server/${{ steps.branch.outputs.version_name }}
240-
cp -r server/${{ steps.branch.outputs.branch_name }} server/${{ steps.branch.outputs.version_name }}
241-
fi
242-
243-
# Clean up empty directories and artifacts
244-
find . -type d -empty -delete
245-
rm -rf artifacts
246-
247-
- name: Add various redirects for go.php and user_manual english version
248-
run: |
249-
# Fetch default branch to get base redirect files
250-
git fetch origin ${{ github.event.repository.default_branch }}
251-
252-
# Checkout both redirect files from default branch
253-
git checkout origin/${{ github.event.repository.default_branch }} -- go.php/index.html user_manual/index.html
254-
255-
# Create deployment directories and move redirects into place
256-
mkdir -p server/${{ steps.branch.outputs.branch_name }}/{go.php,user_manual}
257-
mv go.php/index.html server/${{ steps.branch.outputs.branch_name }}/go.php/
258-
mv user_manual/index.html server/${{ steps.branch.outputs.branch_name }}/user_manual/
259-
260-
- name: Upload staged site
261-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
262-
with:
263-
name: staged-site
264-
path: server/
265262

266263
check:
267264
name: Check staged documentation
@@ -283,15 +280,14 @@ jobs:
283280
jobSummary: true
284281
args: |
285282
--offline --no-progress --verbose
286-
--remap "https://docs.nextcloud.com/server/${{ needs.stage.outputs.branch_name }} file://$(pwd)/server/${{ needs.stage.outputs.branch_name }}"
283+
--remap "https://docs.nextcloud.com/server/${{ needs.stage.outputs.branch_name }} file://$(pwd)/server/${{ needs.stage.outputs.branch_name }}/"
287284
'server/${{ needs.stage.outputs.branch_name }}/**/*.html'
288285
289-
290286
deploy:
291287
name: Deploy documentation to gh-pages
292288
needs: [stage, check]
293289
runs-on: ubuntu-latest
294-
if: github.event_name == 'push'
290+
# if: github.event_name == 'push'
295291

296292
permissions:
297293
contents: write
@@ -335,7 +331,7 @@ jobs:
335331
336332
find . -type d -empty -delete
337333
338-
# QUickly log the directory structure for debugging purposes
334+
# Quickly log the directory structure for debugging purposes
339335
echo "Directory structure after applying staged site:"
340336
find server -type d -print
341337

0 commit comments

Comments
 (0)