Step 1 - generate a personal access token at Github
Go to https://github.com/settings/applications#personal-access-tokens and Generate new token
Step 2 - add an environment variable to your Travis-CI project.
- Go to project Settings and choose Environment Variables
- Variable Name: DEPLOY_REPO
- Variable Value: https://{github_access_token}@github.com/{github_username}/{repository_name}.git (for example: https://8260b82839xx2d19387a51bafca4d5425da7@github.com/ruanyl/ruanyl.github.io.git)
Step 3 - edit .travis.yml file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | language: node_js node_js: - "0.12" before_install: - npm install -g hexo install: - npm install before_script: - git config --global user.name 'ruanyl' - git config --global user.email 'ruanyu1@gmail.com' script: - hexo generate after_success: - mkdir .deploy - cd .deploy - git init - git remote add origin $DEPLOY_REPO - cp -r ../public/* . - git add -A . - git commit -m 'Site updated' - git push --force --quiet origin master |
Notice! If you have 3rd party themes installed
You have to add the theme repo as a gitmodule, add a file named: .gitmodules under the root dir of your hexo blog and add:
1 2 3 | [submodule "alex"] path = themes/alex url = https://github.com/ruanyl/hexo-theme-alex.git
from http://blog.bigruan.com/2015-03-09-Continuous-Integration-Your-Hexo-Blog-With-TravisCI/
|
No comments:
Post a Comment