Skip to content

Instantly share code, notes, and snippets.

Last active Feb 28, 2017
What would you like to do?
using travis-ci to build using docpad, and publish to github pages

use travis-ci to publish to github



The docpad-plugin-ghpages uses the following information to stitch a new repo with contents of ./out directory onto root of your gh-pages branch:

  • git config
  • git config
  • git config remote.origin.url - uses this url for the git push to your gh-pages branch

It turns out that your github token is a valid username, such that $$user/$repo.git is a valid, authorized git url. Any process that can grab valid values for these three pieces of information will be able to produce new changes in

Using to retrieve all three pieces of information from the output travis encrypt allows you to echo the user name and email for debugging, and primes travis for a successful run of docpad deploy-ghpages.

example travis

language: node_js
- ./
- docpad deploy-ghpages
  - FOO="BAR"
  - GH_REPO="medevice-users/gallery"

Encode tokens

# append a travis secret to .travis.yml
# include some known debuggable strings along with your secret
# commit the result

travis encrypt --add -r user-org-name/repo-name 'GIT_NAME="Your Committer Name [via travis key]" GH_TOKEN=ahead0fxxxxxxxxxxxxxxxxxxx'


If you have a .travis.yml already, this will add a secret variable. Make sure to delete any previous secret, so that the only one available is this one. My brief testing suggests all pieces of information are required, and you'll be glad you can echo some non-sensitive bits from the same serialization for debugging later.



  • github issues tokens, you can grab one using curl
  • craft a special remote push url, make sure git repo is configured using this url with your token.
  • encrypt several environment variables, some sensitive along with some that are not so that you can echo to debug.


likely problems


  • send a few variables you feel comfortable echoing for debug
  • make sure you that git config remote.origin.url has output.
  • make sure git is configured with your username and email

Having difficulty getting this working on travis. For some reason, git is not getting the new specially authorized remote url.

Fails with:

Using worker:

$ export FOO="BAR"
$ export GH_REPO="medevice-users/gallery"
$ export GIT_NAME=[secure]
$ export GIT_EMAIL=[secure]
$ export GH_TOKEN=[secure]
$ git clone --depth=50 --branch=master git:// medevice-users/gallery
Cloning into 'medevice-users/gallery'...
remote: Counting objects: 798, done.�[K
$ export REPO_URL="https://$$GH_REPO.git"
$ ./
HELLO WORLD set up medevice-users/gallery [via travis] for Ben West [via travis] <>
# HEAD detached at d797dbf
nothing to commit, working directory clean
remotes pre pre-authorized remote url
old	git:// (fetch)
old	git:// (push)
$ docpad deploy-ghpages
�[32minfo:�[39m Welcome to DocPad v6.46.4
�[32minfo:�[39m Contribute:
�[32minfo:�[39m Plugins: cleanurls, coffeescript, eco, ghpages, jade, less, livereload, marked, paged, partials, related, stylus, text
�[32minfo:�[39m Environment: static
�[32minfo:�[39m Deployment to GitHub Pages starting...
�[32minfo:�[39m Generating...
�[32minfo:�[39m Generated 45/45 files in 6.74 seconds
Initialized empty Git repository in /home/travis/build/medevice-users/gallery/out/.git/

*** Please tell me who you are.


  git config --global ""
  git config --global "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <travis@testing-worker-linux-2-2-16953-linux-6.(none)>) not allowed
�[31merror:�[39m Something went wrong with the action
�[31merror:�[39m An error occured: 
*** Please tell me who you are.


  git config --global ""
  git config --global "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <travis@testing-worker-linux-2-2-16953-linux-6.(none)>) not allowed

    at ChildProcess.<anonymous> (/home/travis/build/medevice-users/gallery/node_modules/docpad-plugin-ghpages/node_modules/safeps/out/lib/safeps.js:154:21)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

The command "docpad deploy-ghpages" exited with 1.

Done. Your build exited with 1.

Runs equivalent of?:

rough bash translation of

rootPath="./" # ?
rm -Rm out/.git
( cd $rootPath/out; 
  url=$(git config remote.origin.url)
  lastCommit=$(git log --oneline | head -n 1)
  git init
  git add .
  git commit -m $lastCommit
  git push --force $url master:gh-pages


If you are wanting to open-source your website, we suggest using the Creative Commons Attribution License for content and the MIT License for code.

echo "BUMP HELLO WORLD set up $GH_REPO [via travis] for $GIT_NAME <${GIT_EMAIL}>"
export REPO_URL="https://$$GH_REPO.git"
git config --global "$GIT_EMAIL"
git config --global "$GIT_NAME"
git branch -a
echo "STATUS"
git status
git remote rename origin old
echo "remotes pre pre-authorized remote url"
git remote -v
git remote add origin $REPO_URL
git config remote.origin.url $REPO_URL
echo "DEBUG, cd out"
test -d out && (
cd out
echo -n ""
git config
echo -n ""
git config
) || echo "fresh build, no out directory"

using travis ci to publish to github pages

github has made it harder to use several features, gists and cloning in particular. This fixes both:

git clone $CLONE_URL travis_github_pages


This comment has been minimized.

Copy link
Owner Author

@bewest bewest commented Jul 29, 2013

@balupton you might like this.


This comment has been minimized.

Copy link

@balupton balupton commented Aug 22, 2013

just noticed it :) github doesn't notify you about gist mentions unfortunately. Retweeted on the DocPad twitter account. Awesome work! 👍


This comment has been minimized.

Copy link

@nfriedly nfriedly commented Oct 16, 2013

So, this works great for me, but I just noticed the git push command outputs the URL to my git repo, including the private token, in the console output that is available for the public to see on

Do you have a way to work around this?

I sent in a pull request with a new quiet config option - set plugins.ghpages.quiet = true in your docpad config file to enable it: docpad/docpad-plugin-ghpages#15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment