Skip to content

Commit cfc3d01

Browse files
Copilotskjnldsv
andcommitted
feat: deploy full merged documentation to Netlify preview
Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/131cd607-27ec-4bd2-abed-7ede744acad9 Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
1 parent f477c06 commit cfc3d01

1 file changed

Lines changed: 62 additions & 37 deletions

File tree

.github/workflows/sphinxbuild.yml

Lines changed: 62 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,64 @@ jobs:
379379
path: stage/
380380
key: staged-docs-${{ github.sha }}
381381

382+
# ========================================================================
383+
# ASSEMBLE FULL NETLIFY PREVIEW CONTENT
384+
# ========================================================================
385+
# Combine the existing gh-pages content (all versions) with the newly
386+
# built artifacts so the Netlify preview shows the complete site.
387+
#
388+
# Structure of the merged output (netlify-full/):
389+
# netlify-full/
390+
# ├── index.html ← generated version listing
391+
# ├── latest/ ← from gh-pages or newly built
392+
# ├── stable/ ← from gh-pages or newly built
393+
# └── <N>/ ← older versions from gh-pages
394+
# ========================================================================
395+
- name: Assemble full documentation for Netlify preview
396+
run: |
397+
branch="${{ steps.branch.outputs.branch_name }}"
398+
additional="${{ steps.branch.outputs.additional_deployment }}"
399+
400+
mkdir -p netlify-full
401+
402+
# Start with the full existing gh-pages content as the base
403+
if [ -d "validation-context/server" ]; then
404+
cp -r validation-context/server/. netlify-full/
405+
fi
406+
407+
# Override the current branch's folder with the freshly built content
408+
rm -rf "netlify-full/${branch}"
409+
cp -r "stage/${branch}" "netlify-full/${branch}"
410+
411+
# For the highest stable branch, also override its versioned folder
412+
if [ -n "${additional}" ]; then
413+
rm -rf "netlify-full/${additional}"
414+
cp -r "stage/${branch}" "netlify-full/${additional}"
415+
fi
416+
417+
# Generate a root index.html listing all version folders
418+
echo '<!DOCTYPE html>' > netlify-full/index.html
419+
echo '<html lang="en"><head>' >> netlify-full/index.html
420+
echo '<meta charset="UTF-8">' >> netlify-full/index.html
421+
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0">' >> netlify-full/index.html
422+
echo '<title>Nextcloud Documentation Preview</title>' >> netlify-full/index.html
423+
echo '</head><body>' >> netlify-full/index.html
424+
echo '<h1>Nextcloud Documentation Preview</h1><ul>' >> netlify-full/index.html
425+
for version_dir in netlify-full/*/; do
426+
version="$(basename "$version_dir")"
427+
echo "<li><a href=\"${version}/\">${version}</a></li>" >> netlify-full/index.html
428+
done
429+
echo '</ul></body></html>' >> netlify-full/index.html
430+
431+
echo "Full Netlify deploy structure:"
432+
find netlify-full -maxdepth 2 -type d
433+
434+
- name: Cache full documentation for Netlify preview
435+
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
436+
with:
437+
path: netlify-full/
438+
key: netlify-full-docs-${{ github.sha }}
439+
382440
# ============================================================================
383441
# DEPLOY
384442
# ============================================================================
@@ -526,50 +584,17 @@ jobs:
526584
pull-requests: write
527585

528586
steps:
529-
- name: Restore staged artifacts from cache
587+
- name: Restore full documentation from cache
530588
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
531589
with:
532-
path: stage/
533-
key: staged-docs-${{ github.sha }}
590+
path: netlify-full/
591+
key: netlify-full-docs-${{ github.sha }}
534592
fail-on-cache-miss: true
535593

536-
- name: Assemble Netlify deploy directory
537-
run: |
538-
branch="${{ needs.stage-and-check.outputs.branch_name }}"
539-
mkdir -p netlify-deploy
540-
541-
# Flatten stage/<branch>/<manual>/ into netlify-deploy/<manual>/
542-
for manual_dir in "stage/${branch}/"/*/; do
543-
if [ -d "$manual_dir" ]; then
544-
manual_name="$(basename "$manual_dir")"
545-
cp -r "$manual_dir" "netlify-deploy/${manual_name}"
546-
fi
547-
done
548-
549-
# Create a root index linking to each manual
550-
cat > netlify-deploy/index.html << 'ENDHTML'
551-
<!DOCTYPE html>
552-
<html lang="en">
553-
<head>
554-
<meta charset="UTF-8">
555-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
556-
<title>Nextcloud Documentation Preview</title>
557-
</head>
558-
<body>
559-
<h1>Nextcloud Documentation Preview</h1>
560-
<ul>
561-
<li><a href="user_manual/">User Manual</a></li>
562-
<li><a href="admin_manual/">Administration Manual</a></li>
563-
<li><a href="developer_manual/">Developer Manual</a></li>
564-
</ul>
565-
</body>
566-
</html>
567-
ENDHTML
568-
569594
- name: Deploy to Netlify
570595
uses: nwtgck/actions-netlify@4cbaf4c08f1a7bfa537d6113472ef4424e4eb654 # v3.0
571596
with:
572-
publish-dir: './netlify-deploy'
597+
publish-dir: './netlify-full'
573598
production-deploy: false
574599
github-token: ${{ secrets.GITHUB_TOKEN }}
575600
deploy-message: "Preview for PR #${{ github.event.number }}"

0 commit comments

Comments
 (0)