Permalink
Browse files

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
  • Loading branch information...
mumoshu committed Aug 23, 2017
1 parent c90b40e commit 0e01bfc88070478c77cc7151fdf15403c792ba29
Showing with 58 additions and 1 deletion.
  1. +5 −0 .travis.yml
  2. +10 −1 Makefile
  3. +1 −0 ci/.gitignore
  4. +42 −0 ci/publish-docs-as-bot.sh
  5. BIN kube-aws-bot-git-ssh-key.enc
View
@@ -6,3 +6,8 @@ script:
- make test-with-cover
after_success:
- bash <(curl -s https://codecov.io/bash)
deploy:
provider: script
script: ci/publish-docs-as-bot.sh
on:
branch: master
View
@@ -42,6 +42,15 @@ generate-docs: docs-dependencies
serve-docs: docs-dependencies
gitbook serve
# For publishing to the `git remote` named `mumoshu` linked to the repo url `git@github.com:mumoshu/kube-aws.git`, the env vars should be:
# REPO=mumoshu/kube-aws REMOTE=mumoshu make publish-docs
# For publishing to the `git remote` named `origin` linked to the repo url `git@github.com:kubernetes-incubator/kube-aws.git`, the env vars should be:
# REPO=kubernetes-incubator/kube-aws REMOTE=origin make publish-docs
# Or just:
# make publish-docs
.PHONY: publish-docs
publish-docs: REPO ?= kubernetes-incubator/kube-aws
publish-docs: REMOTE ?= origin
publish-docs: generate-docs
NODE_DEBUG=gh-pages gh-pages -d _book
NODE_DEBUG=gh-pages gh-pages -d _book -r git@github.com:$(REPO).git -o $(REMOTE)
View
@@ -0,0 +1 @@
kube-aws-bot-git-ssh-key*
View
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -ve
# This script:
# - assumes you've created a ssh key used by kube-aws-bot to ssh into github:
# https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
# - utilizes Travis CI's file encryption feature for encrypting ssh keys
# It requires the following command beforehand:
# $ gem install travis
# $ travis login --auto
# $ travis encrypt-file ci/kube-aws-bot-git-ssh-key --repo <your github user or organization>/kube-aws
# And then change this line to the one output from the `travis encrypt-file` command above
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
## Prevent the following error:
## Permissions 0644 for '/home/travis/gopath/src/github.com/kubernetes-incubator/kube-aws/ci/kube-aws-bot-git-ssh-key' are too open.
## ...
## bad permissions: ignore key: /home/travis/gopath/src/github.com/kubernetes-incubator/kube-aws/ci/kube-aws-bot-git-ssh-key
chmod 600 ci/kube-aws-bot-git-ssh-key
# Finally run the following command to add the encrypted key to the git repo:
# $ git add kube-aws-bot-git-ssh-key.enc
# $ $ git commit -m '...'
echo -e "Host github.com\n\tStrictHostKeyChecking no\nIdentityFile $(pwd)/ci/kube-aws-bot-git-ssh-key\n" >> ~/.ssh/config
set +e
ssh git@github.com
status=$?
set -e
if [ $status -ne 1 ]; then
echo ssh connection check to github failed: ssh command exited with status $status 1>&2
exit 1
fi
echo Node.js $(node -v) is installed/being used
REPO=$TRAVIS_REPO_SLUG make publish-docs
View
Binary file not shown.

0 comments on commit 0e01bfc

Please sign in to comment.