|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2019 Google LLC |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +set -eo pipefail |
| 18 | + |
| 19 | +# build jsdocs (Python is installed on the Node 10 docker image). |
| 20 | +if [[ -z "$CREDENTIALS" ]]; then |
| 21 | + # if CREDENTIALS are explicitly set, assume we're testing locally |
| 22 | + # and don't set NPM_CONFIG_PREFIX. |
| 23 | + export NPM_CONFIG_PREFIX=/home/node/.npm-global |
| 24 | + export PATH="$PATH:/home/node/.npm-global/bin" |
| 25 | + cd $(dirname $0)/../.. |
| 26 | +fi |
| 27 | +npm install |
| 28 | +npm run docs |
| 29 | + |
| 30 | +# create docs.metadata, based on package.json and .repo-metadata.json. |
| 31 | +npm i json@9.0.6 -g |
| 32 | +python3 -m pip install --user gcp-docuploader |
| 33 | +python3 -m docuploader create-metadata \ |
| 34 | + --name=$(cat .repo-metadata.json | json name) \ |
| 35 | + --version=$(cat package.json | json version) \ |
| 36 | + --language=$(cat .repo-metadata.json | json language) \ |
| 37 | + --distribution-name=$(cat .repo-metadata.json | json distribution_name) \ |
| 38 | + --product-page=$(cat .repo-metadata.json | json product_documentation) \ |
| 39 | + --github-repository=$(cat .repo-metadata.json | json repo) \ |
| 40 | + --issue-tracker=$(cat .repo-metadata.json | json issue_tracker) |
| 41 | +cp docs.metadata ./docs/docs.metadata |
| 42 | + |
| 43 | +# deploy the docs. |
| 44 | +if [[ -z "$CREDENTIALS" ]]; then |
| 45 | + CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73713_docuploader_service_account |
| 46 | +fi |
| 47 | +if [[ -z "$BUCKET" ]]; then |
| 48 | + BUCKET=docs-staging |
| 49 | +fi |
| 50 | +python3 -m docuploader upload ./docs --credentials $CREDENTIALS --staging-bucket $BUCKET |
0 commit comments