Skip to content

Commit

Permalink
build: deploy new docs (elastic#7409)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkajtoch committed Jan 6, 2024
1 parent e353a38 commit 2b34c25
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
11 changes: 10 additions & 1 deletion scripts/deploy/build_docs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@

set -e

# 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 base image from pre_command.sh
echo "Building docs using ${DOCKER_BASE_IMAGE} Docker image"
docker pull "$DOCKER_BASE_IMAGE"
docker run \
--rm -i \
--env HOME=/tmp \
--env DOCS_BASE_URL="$DOCS_BASE_URL" \
--"user=$(id -u)":"$(id -g)" \
--volume "$PWD":/app \
--workdir /app \
"$DOCKER_BASE_IMAGE" \
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'
9 changes: 8 additions & 1 deletion scripts/deploy/deploy_docs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,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 \
Expand All @@ -81,11 +82,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
Expand Down
5 changes: 4 additions & 1 deletion website/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 /<baseUrl>/ pathname under which your site is served
baseUrl: '/',
baseUrl,

onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
Expand Down

0 comments on commit 2b34c25

Please sign in to comment.