Skip to content

Instantly share code, notes, and snippets.

@HoverBaum
Last active April 18, 2017 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HoverBaum/524528aec1032b29669fe9cc82dba066 to your computer and use it in GitHub Desktop.
Save HoverBaum/524528aec1032b29669fe9cc82dba066 to your computer and use it in GitHub Desktop.
Travis config to deploy a Hexo based site using FTP.
# FTP deploy Hexo based site using Travis-ci.org
# https://gist.github.com/HoverBaum/524528aec1032b29669fe9cc82dba066
#
# 1. Copy this file to the root of your repository, then rename it to '.travis.yml'
# 2. Replace 'YOUR NAME' and 'YOUR EMAIL'
# 3. Create "Environment Variables" in travis. Make sure to not show them in the output.
# - FTP_USER: The username for FTP transfer.
# - FTP_PASSWORD: Password for the user.
# 4. Replace "DOMAIN.TLD" with your FTP domain and maybe the path where to put things.
#
# This should also work with other static site generators. Just replace hexo
# with your generator.
language: node_js
node_js:
- "6"
# Only build the master branch.
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 'YOUR NAME'
- git config --global user.email 'YOUR EMAIL'
# Generate static files.
script:
- hexo generate
# Upload site using FTP.
# -exec must be closed with ";" which must be escaped (hence the "s).
# Finds all files and calls curl to upload them for every file.
after_success:
'find public -type f -exec curl -u $FTP_USER:$FTP_PASSWORD --ftp-create-dirs -T {} ftp://DOMAIN.TLD/{} ";"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment