Skip to content

Commit e241719

Browse files
authored
build: add configuration for automated doc deployment (#722)
1 parent 7742bb0 commit e241719

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

.kokoro/release/docs.cfg

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# service account used to publish up-to-date docs.
2+
before_action {
3+
fetch_keystore {
4+
keystore_resource {
5+
keystore_config_id: 73713
6+
keyname: "docuploader_service_account"
7+
}
8+
}
9+
}
10+
11+
# doc publications use a Python image.
12+
env_vars: {
13+
key: "TRAMPOLINE_IMAGE"
14+
value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user"
15+
}
16+
17+
# Download trampoline resources.
18+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
19+
20+
# Use the trampoline script to run in docker.
21+
build_file: "nodejs-storage/.kokoro/trampoline.sh"
22+
23+
env_vars: {
24+
key: "TRAMPOLINE_BUILD_FILE"
25+
value: "github/nodejs-storage/.kokoro/release/docs.sh"
26+
}

.kokoro/release/docs.sh

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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

Comments
 (0)