Created
August 11, 2016 03:19
-
-
Save HoverBaum/d11361337d2c59f0de591c9c9390c1a9 to your computer and use it in GitHub Desktop.
Deploy Hexo blog using Travis.
This file contains hidden or 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
# Deploy hexo site by travis-ci | |
# https://github.com/jkeylu/deploy-hexo-site-by-travis-ci | |
# LICENSE: MIT | |
# | |
# 1. Copy this file to the root of your repository, then rename it to '.travis.yml' | |
# 2. Replace 'YOUR NAME' and 'YOUR EMAIL' at line 29 | |
# 3. Add an Environment Variable 'DEPLOY_REPO' | |
# 1. Generate github access token on https://github.com/settings/applications#personal-access-tokens | |
# 2. Add an Environment Variable on https://travis-ci.org/{github username}/{repository name}/settings/env_vars | |
# Variable Name: DEPLOY_REPO | |
# Variable Value: https://{githb access token}@github.com/{github username}/{repository name}.git | |
# Example: DEPLOY_REPO=https://[email protected]/jkeylu/test-hexo-on-travis-ci.git | |
# 4. Make sure Travis is configured to hide your Variable, else others will see your access token and can mess with all your repos. | |
language: node_js | |
# Every once in a while this should be bumped up | |
# https://docs.travis-ci.com/user/languages/javascript-with-nodejs#Choosing-Node-versions-to-test-against | |
node_js: | |
- "6" | |
# Only create a new version on pushes to certain branches. | |
branches: | |
only: | |
- master | |
before_install: | |
- npm install -g hexo | |
install: | |
- npm install | |
# Notice: Replace 'YOUR NAME' and 'YOUR EMAIL' | |
before_script: | |
- git config --global user.name 'Travis' | |
- git config --global user.email '[email protected]' | |
# - git clone git://github.com/heroicyang/hexo-theme-modernist.git themes/modernist | |
# Maybe add minification scripts here | |
script: | |
- hexo generate | |
after_success: | |
- mkdir .deploy # Create a folder to use for teh pages branch | |
- cd .deploy | |
- git clone --depth 1 --branch gh-pages --single-branch $DEPLOY_REPO . || (git init && git remote add -t gh-pages origin $DEPLOY_REPO) | |
- rm -rf ./* # Clear old verion | |
- cp -r ../public/* . # Copy over files for new version | |
- git add -A . | |
- git commit -m 'Site updated' # Make a new commit for new version | |
- git branch -m gh-pages | |
- git push -q -u origin gh-pages # Push silently so we don't leak information |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment