Skip to content

Instantly share code, notes, and snippets.

@xl1
Last active August 29, 2015 14:01
Show Gist options
  • Save xl1/1a38373cbb750036b56c to your computer and use it in GitHub Desktop.
Save xl1/1a38373cbb750036b56c to your computer and use it in GitHub Desktop.
GitHub Pages を Travis に build & deploy させるようにした

GitHub Pages を Travis に build & deploy させるようにした

GerberaGitHub pages を Travis に任せることにしたのでメモしとく

clone

Travis, 最初に git clone --branch=master して、 master ブランチだけを持ってくることになっている。 gh-pages ブランチもほしいので .travis.yml

git fetch origin gh-pages:gh-pages
git checkout gh-pages

とかやった。

一度ローカルの Ubuntu 12.04 (VM) で試そうとして、同じように git clone --branch=master したら、なぜかそのまま git checkout gh-pages できてしまって混乱した。 git version したら 1.7.9 とか言われたのでこれが原因っぽかった。 1.7.10 で git clone --single-branch オプションが追加されて、 --depth を指定するとデフォルトでひとつのブランチだけを clone するようになったっぽい。

--[no-]single-branch

Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote's HEAD points at. When creating a shallow clone with the --depth option, this is the default, unless --no-single-branch is given to fetch the histories near the tips of all branches.

Git - git-clone Documentation

最新の Git 1.9.3 を入れたら思ったとおりに動くようになった。

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

あと vagrant で npm install -g しようとするとコケるので、 npm install -g --no-bin-links とやるとうまくいく。

build

browserify する:

git checkout master -- src
coffee -c src
browserify index.js > Gerbera.js

index.js を以下のようにしてみたのでブラウザなら window.Gerbera に生えるし node なら require できる:

var Gerbera = require('./src/Gerbera');
if('self' in global){
  global.Gerbera = Gerbera;
} else {
  module.exports = Gerbera;
}

deploy

次のページを参考にして GitHub のアクセストークンをつくってこれやった:

gem install travis
travis encrypt --add -r xl1/gerbera "GH_TOKEN=トークン"

久々に gem install しようとしたら certificate verify failed とか言われてコケたので、調べて証明書をなんかやったら直った。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment