Skip to content

Commit 35c8a31

Browse files
committed
refactor: Dynamic docs upload configuration
1 parent cdf948b commit 35c8a31

File tree

6 files changed

+29
-21
lines changed

6 files changed

+29
-21
lines changed

.github/workflows/deploy-docs-next.yaml renamed to .github/workflows/deploy-vitepress-docs.yaml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Sample workflow for building and deploying a VitePress site to GitHub Pages
2-
#
3-
name: Deploy VitePress site to Pages (next)
2+
name: Deploy VitePress site to gh-pages
43

54
on:
65
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
@@ -60,7 +59,14 @@ jobs:
6059
- name: Build jsdoc
6160
run: npm run jsdoc-generate
6261
- name: Build vitepress build
63-
run: npm run docs:build
62+
run: |
63+
cd packages/documentation
64+
# The base output
65+
npm run build:vitepress -- --base="/${{ github.event.repository.name }}/${DOC_VERSION}/"
66+
npm run build:assets -- ./dist
67+
# The alias output
68+
npm run build:vitepress -- --base="/${{ github.event.repository.name }}/${DOC_ALIAS}/" --outDir="dist-${DOC_ALIAS}"
69+
npm run build:assets -- ./dist-${DOC_ALIAS}
6470
- name: Build Schema
6571
run: |
6672
npm run schema-generate
@@ -74,16 +80,19 @@ jobs:
7480
run: |
7581
rm -rf ./gh-pages/schema
7682
cp -R ./site/schema ./gh-pages/
77-
rm -rf ./gh-pages/${DOC_VERSION}/
83+
rm -rf ./gh-pages/${DOC_VERSION}
84+
rm -rf ./gh-pages/${DOC_ALIAS}
85+
86+
# Main version route
7887
cp -R ./packages/documentation/dist ./gh-pages/${DOC_VERSION}/
88+
cp -R ./site/api ./gh-pages/${DOC_VERSION}/api
89+
90+
# Alias route. E.g., next, latest, stable, etc.
91+
# For vitepress must be a copy with different config, not a symlink
92+
cp -R ./packages/documentation/dist-${DOC_ALIAS} ./gh-pages/${DOC_ALIAS}/
93+
cp -R ./site/api ./gh-pages/${DOC_ALIAS}/api
94+
7995
cp ./scripts/resources/custom404.html ./gh-pages/404.html
80-
- name: Create or update alias route
81-
run: |
82-
cd ./gh-pages
83-
# Remove existing alias if it exists (file or symlink)
84-
rm -rf "${DOC_ALIAS}"
85-
# Create symlink from alias to version directory
86-
ln -s "${DOC_VERSION}" "${DOC_ALIAS}"
8796
- name: Publish Docs
8897
run: |
8998
cd ./gh-pages

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
"coverage": "npm run coverage --workspaces",
3030
"jsdoc": "npm run jsdoc-generate && open-cli site/api/index.html",
3131
"jsdoc-generate": "jsdoc -c ./jsdoc-workspace.json -t $(node -p 'path.dirname(require.resolve(\"docdash\"))') ./ || (echo 'Error during JSDoc generation! Check log.' && exit 1)",
32-
"docs:dev": "npm --prefix packages/documentation run dev",
33-
"docs:build": "npm --prefix packages/documentation run build",
34-
"docs:preview": "npm --prefix packages/documentation run preview",
3532
"schema-generate": "node ./scripts/buildSchema.js ui5",
3633
"schema-workspace-generate": "node ./scripts/buildSchema.js ui5-workspace",
3734
"generate-cli-doc": "node ./scripts/generateCliDoc.js",

packages/documentation/.vitepress/config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import MarkdownItImplicitFigures from "markdown-it-implicit-figures";
77

88
export default defineConfig({
99

10-
base: "/cli/v5/", // GitHub Pages deployment base path
10+
// Would be set in CI job via CLI arguments. For local development, it's just root.
11+
base: "/",
1112
srcDir: "docs",
1213
outDir: "dist",
1314
lang: "en-US",
@@ -274,7 +275,7 @@ function guide() {
274275
},
275276
{
276277
text: "API Reference",
277-
link: "https://ui5.github.io/cli/api/index.html",
278+
link: "./api/index.html",
278279

279280
},
280281

packages/documentation/docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import VPButton from "vitepress/dist/client/theme-default/components/VPButton.vu
1010
const { isDark } = useData()
1111
</script>
1212

13-
<img :src="isDark ? '/cli/v5/images/O_UI5_H_noBG.png' : '/cli/v5/images/UI5_logo_wide.png'" alt="UI5 logo" style="max-width: 100%; height: auto;">
13+
<img :src="isDark ? './images/O_UI5_H_noBG.png' : './images/UI5_logo_wide.png'" alt="UI5 logo" style="max-width: 100%; height: auto;">
1414

1515
# UI5 CLI
1616

packages/documentation/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"scripts": {
2525
"start": "vitepress dev --open",
2626
"dev": "vitepress dev",
27-
"build": "vitepress build && cp -r ./docs/images ./dist/images",
27+
"build:vitepress": "vitepress build",
28+
"build:assets": "sh -c 'DEST_DIR=${1:-./dist}; cp -r ./docs/images \"$DEST_DIR/images\"' --",
2829
"preview": "vitepress preview --port 8080",
2930
"serve-docs": "npm run build && npm run preview"
3031
},

0 commit comments

Comments
 (0)