Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Deploy Hexo blog using Travis.
# Deploy hexo site by travis-ci
# 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
# 2. Add an Environment Variable on{github username}/{repository name}/settings/env_vars
# Variable Name: DEPLOY_REPO
# Variable Value: https://{githb access token}{github username}/{repository name}.git
# Example: DEPLOY_REPO=
# 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
- "6"
# Only create a new version on pushes to certain branches.
- master
- npm install -g hexo
- npm install
# Notice: Replace 'YOUR NAME' and 'YOUR EMAIL'
- git config --global 'Travis'
- git config --global ''
# - git clone git:// themes/modernist
# Maybe add minification scripts here
- hexo generate
- 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
You can’t perform that action at this time.