-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add buildkite step to build new docs website (#7850)
- Loading branch information
Showing
5 changed files
with
90 additions
and
7 deletions.
There are no files selected for viewing
12 changes: 10 additions & 2 deletions
12
.buildkite/pipelines/pipeline_pull_request_deploy_docs.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
## 🏠/.buildkite/pipelines/pipeline_pull_request_deploy_docs.yml | ||
|
||
steps: | ||
- agents: | ||
- command: .buildkite/scripts/pipelines/pipeline_deploy_docs.sh | ||
label: ":newspaper: Build and deploy EUI documentation website" | ||
agents: | ||
provider: "gcp" | ||
command: .buildkite/scripts/pipelines/pipeline_deploy_docs.sh | ||
if: build.branch != "main" # We don't want to deploy docs on main, only on manual release | ||
- command: .buildkite/scripts/pipelines/pipeline_deploy_new_docs.sh | ||
label: ":docusaurus: Build and deploy new documentation website" | ||
agents: | ||
provider: gcp | ||
machineType: "n2-standard-2" | ||
image: "family/eui-ubuntu-2204" | ||
if: build.branch != "main" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/bash | ||
# Build and deploy new documentation website | ||
|
||
set -eo pipefail | ||
|
||
# include .bash_profile and utils | ||
source ~/.bash_profile | ||
source .buildkite/scripts/common/utils.sh | ||
|
||
# Enable corepack to expose yarn cli command | ||
corepack enable | ||
|
||
# Print out debug information | ||
echo "Node.js version: $(node -v)" | ||
echo "Yarn version: $(yarn -v)" | ||
|
||
# Calculate paths and directories | ||
if [[ -n "${BUILDKITE_PULL_REQUEST}" ]] && [[ "${BUILDKITE_PULL_REQUEST}" != "false" ]]; then | ||
bucket_directory="pr_${BUILDKITE_PULL_REQUEST}/new-docs/" | ||
echo "Detected a PR preview environment configuration. The built files will be copied to ${bucket_directory}" | ||
else | ||
echo "The script has been triggered with no pull request or tag information. This is a no-op." | ||
exit 1 | ||
fi | ||
|
||
echo "+++ :yarn: Installing dependencies" | ||
yarn | ||
|
||
echo "+++ :yarn: Building @elastic/eui-website and its local dependencies" | ||
|
||
# Pass base url to docusaurus. It must have a leading and trailing slash included. | ||
export DOCS_BASE_URL="/${bucket_directory}" | ||
|
||
yarn workspaces foreach -Rpt --from @elastic/eui-website run build | ||
|
||
echo "+++ Configuring environment for website deployment" | ||
|
||
gcloud auth activate-service-account --key-file <(echo "${GCE_ACCOUNT}") | ||
unset GCE_ACCOUNT | ||
|
||
storage_vault="secret/ci/elastic-eui/website-storage-bucket" | ||
GCLOUD_PROJECT="$(retry 5 vault read -field=google_cloud_project "${storage_vault}")" | ||
GCLOUD_BUCKET="$(retry 5 vault read -field=google_cloud_bucket "${storage_vault}")" | ||
GCLOUD_BUCKET_FULL="${GCLOUD_PROJECT}-${GCLOUD_BUCKET}" | ||
|
||
GCLOUD_CP_ARGS=( | ||
--cache-control="public, max-age=1800, must-revalidate" # set caching policy | ||
--recursive # copy all files recursively | ||
--predefined-acl="publicRead" # ensure copied files are publicly accessible | ||
--gzip-local="js,css,html,svg,png,jpg,ico" # gzip these file extensions before copying to the bucket | ||
) | ||
|
||
# Copy files to the GCS bucket | ||
|
||
echo "+++ :bucket: Copying built files to the bucket" | ||
|
||
# additional protection layer in case bucket_directory is ever unset | ||
if [[ -z "${bucket_directory}" ]]; then | ||
bucket_directory="new-docs/" | ||
fi | ||
|
||
echo "Beginning to copy built files to /${bucket_directory}" | ||
gcloud storage cp "${GCLOUD_CP_ARGS[@]}" packages/website/build/* "gs://${GCLOUD_BUCKET_FULL}/${bucket_directory}" | ||
|
||
echo "New documentation website deployed: https://eui.elastic.co/${bucket_directory}" | buildkite-agent annotate --style "success" --context "deployed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters