From 0a55e2951b3f26a35da80e4f12e02381fdfac690 Mon Sep 17 00:00:00 2001 From: Tomasz Kajtoch Date: Thu, 7 Dec 2023 23:53:55 +0100 Subject: [PATCH] build: deploy new docs (#7409) --- scripts/deploy/build_docs | 11 ++++++++++- scripts/deploy/deploy_docs | 9 ++++++++- website/docusaurus.config.ts | 5 ++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/scripts/deploy/build_docs b/scripts/deploy/build_docs index c15dd68305f..f27146d88a8 100755 --- a/scripts/deploy/build_docs +++ b/scripts/deploy/build_docs @@ -4,14 +4,23 @@ set -e NODE_IMG="docker.elastic.co/eui/ci:6.0" +# Docusaurus must know the base URL to work properly +DOCS_BASE_URL="/new-docs/" +if [ -n "${GIT_PULL_REQUEST_ID}" ] && [ "${GIT_PULL_REQUEST_ID}" != "false" ]; then + DOCS_BASE_URL="/pr_${GIT_PULL_REQUEST_ID}/new-docs/" +fi + +echo "Docusaurus base URL set to: ${DOCS_BASE_URL}" + # Compile using node image echo "Building docs using ${NODE_IMG} Docker image" docker pull $NODE_IMG docker run \ --rm -i \ --env HOME=/tmp \ + --env DOCS_BASE_URL="$DOCS_BASE_URL" \ --"user=$(id -u)":"$(id -g)" \ --volume "$PWD":/app \ --workdir /app \ $NODE_IMG \ - bash -c 'yarn && yarn build && yarn build-docs && yarn build-storybook' + bash -c 'yarn && yarn build && yarn build-docs && yarn build-storybook && yarn --cwd website && yarn --cwd website build' diff --git a/scripts/deploy/deploy_docs b/scripts/deploy/deploy_docs index 2470b3db98f..95e8038834a 100755 --- a/scripts/deploy/deploy_docs +++ b/scripts/deploy/deploy_docs @@ -55,7 +55,8 @@ post_comment_to_gh() printf '\nAdding comment to GitHub Pull Request: %i\n' "${GIT_PULL_REQUEST_ID}" comment="Preview staging links for this PR: - Docs site: https://eui.elastic.co/pr_${GIT_PULL_REQUEST_ID}/ -- Storybook: https://eui.elastic.co/pr_${GIT_PULL_REQUEST_ID}/storybook" +- Storybook: https://eui.elastic.co/pr_${GIT_PULL_REQUEST_ID}/storybook +- New docs site (in development): https://eui.elastic.co/pr_${GIT_PULL_REQUEST_ID}/new-docs/" curl \ --silent \ @@ -78,11 +79,17 @@ publish_to_bucket() -z js,css,html # enable gzip encoding for these extensions ) + # Current docs echo "Copying ${PWD}/docs/* to ${full_bucket_path}" gsutil "${copy_options[@]}" "${PWD}/docs/*" "${full_bucket_path}" + # Storybook echo "Copying ${PWD}/storybook-static/* to ${full_bucket_path}storybook/" gsutil "${copy_options[@]}" "${PWD}/storybook-static/*" "${full_bucket_path}storybook/" + + # New docs + echo "Copying ${PWD}/website/build/* to ${full_bucket_path}new-docs/" + gsutil "${copy_options[@]}" "${PWD}/website/build/*" "${full_bucket_path}new-docs/" } if [[ "$1" != "nodocker" ]]; then diff --git a/website/docusaurus.config.ts b/website/docusaurus.config.ts index feefaf38bcf..8cfeed82f83 100644 --- a/website/docusaurus.config.ts +++ b/website/docusaurus.config.ts @@ -2,16 +2,19 @@ import {themes as prismThemes} from 'prism-react-renderer'; import type {Config} from '@docusaurus/types'; import type * as Preset from '@docusaurus/preset-classic'; +const baseUrl = process.env.DOCS_BASE_URL || '/'; + const config: Config = { title: 'Elastic UI Framework', tagline: 'The framework powering the Elastic Stack', favicon: 'favicon.ico', + trailingSlash: true, // Set the production url of your site here url: 'https://eui.elastic.co', // Set the // pathname under which your site is served - baseUrl: '/', + baseUrl, onBrokenLinks: 'throw', onBrokenMarkdownLinks: 'warn',