From 55468f9647bc0711b8437bbfc617ec965f2c9994 Mon Sep 17 00:00:00 2001 From: Tomasz Kajtoch Date: Thu, 7 Dec 2023 19:26:52 +0100 Subject: [PATCH] build: update `build_docs` and `deploy_docs` to deploy new docusaurus-based docs when available --- scripts/deploy/build_docs | 11 ++++++++++- scripts/deploy/deploy_docs | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/scripts/deploy/build_docs b/scripts/deploy/build_docs index c15dd68305f..c7ca2c59d59 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 && if [[ -d website ]]; then yarn --cwd website && yarn --cwd website build; fi' diff --git a/scripts/deploy/deploy_docs b/scripts/deploy/deploy_docs index 2470b3db98f..d97504046fd 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,19 @@ 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 + if [[ -d "${PWD}/website/build" ]]; then + echo "Copying ${PWD}/website/build/* to ${full_bucket_path}new-docs/" + gsutil "${copy_options[@]}" "${PWD}/website/build/*" "${full_bucket_path}new-docs/" + fi } if [[ "$1" != "nodocker" ]]; then