Last active
August 29, 2015 14:00
-
-
Save kazu69/11389772 to your computer and use it in GitHub Desktop.
Easy setup blogging that uses a github pages and middleman-blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
language: ruby | |
script: bundle exec middleman build | |
env: | |
global: | |
- GIT_COMMITTER_NAME=USERNAME | |
- GIT_COMMITTER_EMAIL=USERNAME-EMAIL | |
- GIT_AUTHOR_NAME=USERNAME | |
- GIT_AUTHOR_EMAIL=USERNAME-EMAIL | |
- secure: "YOUR-TRAVIS-TOKEN" | |
before_script: | |
- git clone --quiet https://github.com/USERNAME/REPOSITORY | |
- pushd build | |
- git checkout -b gh-pages | |
- popd | |
after_success: | |
- cd build | |
- git add -A | |
- git commit -m 'Update' | |
- '[ "$TRAVIS_BRANCH" == "master" ] && [ $GH_TOKEN ] && git push --quiet https://$GH_TOKEN@github.com/USERNAME/REPOSITORY.git gh-pages 2> /dev/null' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install middleman-blog | |
gem install middleman-blog | |
# create blog | |
middleman init blog --template=blog | |
# structure | |
tree -L 2 | |
myblog | |
|- .gitignore | |
|- config.rb | |
|- Gemfile | |
|- Gemfile.lock | |
|- source | |
|- 2012-01-01-example-article.html.markdown | |
|- calendar.html.erb | |
|- feed.xml.builder | |
|- images | |
|- index.html.erb | |
|- javascripts | |
|- layout.erb | |
|- stylesheets | |
|- tag.html.erb | |
# local development server | |
bundle exec middleman server | |
# access | |
open http://localhost:4567 | |
# blog build | |
bundle exec middleman build | |
# publish gh-pages use gem | |
gem install middleman-gh-pages | |
# create Rakefile | |
touch Rakefile | |
echo "require 'middleman-gh-pages'" >> Rakefile | |
# publish | |
bundle exec rake publish | |
# access gh-pages | |
open http://USERNAME.github.io/YOUR-REPOSITORY | |
# auto puslish use travis | |
gem install travis | |
# login travis | |
travis login | |
# sync repository | |
travis sync | |
# create .travis.yml | |
travis init ruby | |
# enable your projects | |
travis enable | |
# open travis browser | |
travis open | |
# get github api token | |
curl -u 'USERNAME' -d '{"scopes":["repo"],"note":"travis-ghpages"}' https://api.github.com/authorizations | |
Enter host password for user 'USERNAME': | |
{ | |
"id": xxxxxxxx, | |
"url": "https://api.github.com/authorizations/xxxxxxxx", | |
"app": { | |
"name": "travis-ghpages (API)", | |
"url": "https://developer.github.com/v3/oauth_authorizations/", | |
"client_id": "00000000000000000000" | |
}, | |
"token": "GITHUB-TOKEN", | |
"note": "travis-ghpages", | |
"note_url": null, | |
"created_at": "2014-04-29T10:18:54Z", | |
"updated_at": "2014-04-29T10:18:54Z", | |
"scopes": [ | |
"repo" | |
] | |
} | |
# get travis token | |
travis encrypt -r USERNAME/YOUR-REPOSITORY "GH_TOKEN=GITHUB-TOKEN" | |
Please add the following to your .travis.yml file: | |
secure: "YOUR-TRAVIS-TOKEN" | |
# edit .travis.yml | |
vi .travis.yml | |
# When you push in the Master branch, it can be build automatically by travis. | |
# Reference URL | |
# http://tricknotes.hateblo.jp/entry/2013/06/17/020229 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment