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

Commit

Permalink
Automate publishing of the dedicated kube-aws documentation site
Browse files Browse the repository at this point in the history
* 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 0e01bfc
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .travis.yml
Expand Up @@ -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
11 changes: 10 additions & 1 deletion Makefile
Expand Up @@ -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)
1 change: 1 addition & 0 deletions ci/.gitignore
@@ -0,0 +1 @@
kube-aws-bot-git-ssh-key*
42 changes: 42 additions & 0 deletions ci/publish-docs-as-bot.sh
@@ -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
Binary file added kube-aws-bot-git-ssh-key.enc
Binary file not shown.

0 comments on commit 0e01bfc

Please sign in to comment.