Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rapids-upload-docs script #56

Merged
merged 1 commit into from
May 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions tools/rapids-upload-docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
set -euo pipefail

checks() {
if [[ ! -d "${RAPIDS_DOCS_DIR}" ]]; then
echo "ERROR: RAPIDS_DOCS_DIR must be a directory."
exit 1
fi

if [[ "${GITHUB_ACTIONS:-false}" != "true" ]]; then
echo "Uploading docs from local builds is not supported."
exit 0
fi

# TODO: remove this block once pull-request previews are supported
if [[ "${RAPIDS_BUILD_TYPE}" == "pull-request" ]]; then
echo "Uploading docs for pull-requests is not yet supported."
exit 0
fi
}


get_s3_dest() {
local PROJECT=$1
local FORMAT=$2

case "${RAPIDS_BUILD_TYPE}" in
# TODO: double check this path once pull-request previews are supported
pull-request)
echo -n "$(rapids-s3-path)docs/${PROJECT}/${FORMAT}"
return
;;
branch|nightly)
echo -n "s3://rapidsai-docs/${PROJECT}/${RAPIDS_VERSION_NUMBER}/${FORMAT}"
return
;;
*)
rapids-echo-stderr "please pass a valid RAPIDS_BUILD_TYPE"
exit 1
;;
esac
}

copy_docs_to_s3() {
local PROJECT_DIR PROJECT PROJECT_FORMAT_DIR FORMAT
for PROJECT_DIR in "${RAPIDS_DOCS_DIR}"/*; do
PROJECT=$(basename "${PROJECT_DIR}")
for PROJECT_FORMAT_DIR in "${PROJECT_DIR}"/*; do
FORMAT=$(basename "${PROJECT_FORMAT_DIR}")

if [[ ! "${FORMAT}" =~ ^(html|txt)$ ]]; then
echo "ERROR: FORMAT must be either 'html' or 'txt'."
exit 1
fi

rapids-logger "Uploading ${RAPIDS_VERSION_NUMBER} ${PROJECT} ${FORMAT} docs to S3."

aws s3 sync \
--no-progress \
--delete \
"${PROJECT_FORMAT_DIR}" \
"$(get_s3_dest "${PROJECT}" "${FORMAT}")"
echo ""
done
done
}

checks
copy_docs_to_s3