Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Commit 0e01bfc

Browse files
committed
Automate publishing of the dedicated kube-aws documentation site
* Print node.js version to debug when the script failed due to an incompatible node.js version * `nvm` for version-locking node.js isn't available in Travis CI's golang image * Read the repo slug(`user/reponame`) from env vars so that we do not need to hard-code it * Improve `make publish-docs` to support various cases * travis builds and local runs against a forked repo
1 parent c90b40e commit 0e01bfc

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ script:
66
- make test-with-cover
77
after_success:
88
- bash <(curl -s https://codecov.io/bash)
9+
deploy:
10+
provider: script
11+
script: ci/publish-docs-as-bot.sh
12+
on:
13+
branch: master

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ generate-docs: docs-dependencies
4242
serve-docs: docs-dependencies
4343
gitbook serve
4444

45+
# For publishing to the `git remote` named `mumoshu` linked to the repo url `[email protected]:mumoshu/kube-aws.git`, the env vars should be:
46+
# REPO=mumoshu/kube-aws REMOTE=mumoshu make publish-docs
47+
# For publishing to the `git remote` named `origin` linked to the repo url `[email protected]:kubernetes-incubator/kube-aws.git`, the env vars should be:
48+
# REPO=kubernetes-incubator/kube-aws REMOTE=origin make publish-docs
49+
# Or just:
50+
# make publish-docs
51+
4552
.PHONY: publish-docs
53+
publish-docs: REPO ?= kubernetes-incubator/kube-aws
54+
publish-docs: REMOTE ?= origin
4655
publish-docs: generate-docs
47-
NODE_DEBUG=gh-pages gh-pages -d _book
56+
NODE_DEBUG=gh-pages gh-pages -d _book -r [email protected]:$(REPO).git -o $(REMOTE)

ci/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kube-aws-bot-git-ssh-key*

ci/publish-docs-as-bot.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
set -ve
4+
5+
# This script:
6+
# - assumes you've created a ssh key used by kube-aws-bot to ssh into github:
7+
# https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
8+
# - utilizes Travis CI's file encryption feature for encrypting ssh keys
9+
10+
# It requires the following command beforehand:
11+
# $ gem install travis
12+
# $ travis login --auto
13+
# $ travis encrypt-file ci/kube-aws-bot-git-ssh-key --repo <your github user or organization>/kube-aws
14+
15+
# And then change this line to the one output from the `travis encrypt-file` command above
16+
openssl aes-256-cbc -K $encrypted_514cf8442810_key -iv $encrypted_514cf8442810_iv -in kube-aws-bot-git-ssh-key.enc -out ci/kube-aws-bot-git-ssh-key -d
17+
18+
## Prevent the following error:
19+
## Permissions 0644 for '/home/travis/gopath/src/github.com/kubernetes-incubator/kube-aws/ci/kube-aws-bot-git-ssh-key' are too open.
20+
## ...
21+
## bad permissions: ignore key: /home/travis/gopath/src/github.com/kubernetes-incubator/kube-aws/ci/kube-aws-bot-git-ssh-key
22+
chmod 600 ci/kube-aws-bot-git-ssh-key
23+
24+
# Finally run the following command to add the encrypted key to the git repo:
25+
# $ git add kube-aws-bot-git-ssh-key.enc
26+
# $ $ git commit -m '...'
27+
28+
echo -e "Host github.com\n\tStrictHostKeyChecking no\nIdentityFile $(pwd)/ci/kube-aws-bot-git-ssh-key\n" >> ~/.ssh/config
29+
30+
set +e
31+
32+
status=$?
33+
set -e
34+
35+
if [ $status -ne 1 ]; then
36+
echo ssh connection check to github failed: ssh command exited with status $status 1>&2
37+
exit 1
38+
fi
39+
40+
echo Node.js $(node -v) is installed/being used
41+
42+
REPO=$TRAVIS_REPO_SLUG make publish-docs

kube-aws-bot-git-ssh-key.enc

3.17 KB
Binary file not shown.

0 commit comments

Comments
 (0)