#!/bin/bash
-# Copyright (c) 2021 Cisco and/or its affiliates.
+# Copyright (c) 2022 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
set -exuo pipefail
-S3_BUCKET="fdio-docs-s3-cloudfront-index"
+if [[ "${SILO}" != "production" ]] ; then
+ echo "WARNING: Doc upload not supported on Jenkins '${SILO}'..."
+ exit 0
+fi
+
CDN_URL="s3-docs.fd.io"
-PYTHON_SCRIPT="/w/workspace/publish_library.py"
if [[ ${JOB_NAME} == *merge* ]]; then
case "${JOB_NAME}" in
*"csit-trending"*)
- SITE_DIR="${WORKSPACE}/resources/tools/trending/_build"
- s3_path="csit/${GERRIT_BRANCH}/trending"
+ workspace_dir="${WORKSPACE}/resources/tools/presentation/_build"
+ bucket_path="/csit/${GERRIT_BRANCH}/trending/"
;;
*"csit-report"*)
- SITE_DIR="${WORKSPACE}/resources/tools/presentation/_build"
- s3_path="csit/${GERRIT_BRANCH}/report"
+ workspace_dir="${WORKSPACE}/resources/tools/presentation/_build"
+ bucket_path="/csit/${GERRIT_BRANCH}/report/"
;;
*"csit-docs"*)
- SITE_DIR="${WORKSPACE}/resources/tools/doc_gen/_build"
- s3_path="csit/${GERRIT_BRANCH}/docs"
+ workspace_dir="${WORKSPACE}/resources/tools/doc_gen/_build"
+ bucket_path="/csit/${GERRIT_BRANCH}/docs/"
+ ;;
+ *"hicn-docs"*)
+ hicn_release="$(git describe --long --match "v*" | cut -d- -f1 | sed -e 's/^v//')"
+ workspace_dir="${WORKSPACE}/build/doc/deploy-site"
+ bucket_path="/hicn/${hicn_release}/"
+ ;;
+ *"vpp-docs"*)
+ vpp_release="$(${WORKSPACE}/build-root/scripts/version rpm-version)"
+ workspace_dir="${WORKSPACE}/build-root/docs/html"
+ bucket_path="/vpp/${vpp_release}/"
;;
*)
die "Unknown job: ${JOB_NAME}"
esac
- echo "INFO: S3 path $s3_path"
+ export TF_VAR_workspace_dir=$workspace_dir
+ export TF_VAR_bucket_path=$bucket_path
+ export AWS_SHARED_CREDENTIALS_FILE=$HOME/.aws/credentials
+ export AWS_DEFAULT_REGION="us-east-1"
echo "INFO: archiving docs to S3"
- python3 $PYTHON_SCRIPT deploy_docs "$S3_BUCKET" "$s3_path" "$SITE_DIR"
+ pushd ..
+ terraform init -no-color
+ terraform apply -no-color -auto-approve
+ popd
- echo "S3 docs: <a href=\"https://$CDN_URL/$s3_path\">https://$CDN_URL/$s3_path</a>"
+ echo "S3 docs: <a href=\"https://${CDN_URL}${bucket_path}\">https://${CDN_URL}${bucket_path}</a>"
fi