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 user.email
git config user.name
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 [email protected]:$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 github.com.
Using prebuild.sh
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
.
language: node_js
before_script:
- ./prebuild.sh
script:
- docpad deploy-ghpages
env:
global:
- FOO="BAR"
- GH_REPO="medevice-users/gallery"
# 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]" [email protected] GH_TOKEN=ahead0fxxxxxxxxxxxxxxxxxxx'
#####
# EOF
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.
- https://gist.github.com/balupton/3939146
- http://rogerz.github.io/blog/2013/02/21/prose-io-github-travis-ci/
- https://github.com/rogerz/rogerz.github.com/blob/49e2c9c4b20748300a2db67a7b23a8a584cad86e/.travis.yml
- https://github.com/docpad/docpad-plugin-ghpages/blob/master/src/ghpages.plugin.coffee
- http://awestruct.org/auto-deploy-to-github-pages/
- http://rogerz.github.io/blog/2013/02/21/prose-io-github-travis-ci/
- obtain new, review, delete tokens from github - leave a note about travis and the date /reason you are creating the token for yourself later!
TL;DR
- 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.
TL;DR
- 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: worker-linux-2-2.bb.travis-ci.org:travis-linux-6
$ export FOO="BAR"
$ export GH_REPO="medevice-users/gallery"
$ export GIT_NAME=[secure]
$ export GIT_EMAIL=[secure]
$ export GH_TOKEN=[secure]
travis_fold:start:git.1
$ git clone --depth=50 --branch=master git://github.com/medevice-users/gallery.git medevice-users/gallery
Cloning into 'medevice-users/gallery'...
remote: Counting objects: 798, done.�[K
[...]
travis_fold:end:install
travis_fold:start:before_script.1
$ export REPO_URL="https://[email protected]/$GH_REPO.git"
travis_fold:end:before_script.1
travis_fold:start:before_script.2
$ ./prebuild.sh
HELLO WORLD set up medevice-users/gallery [via travis] for Ben West [via travis] <[email protected]>
STATUS
# HEAD detached at d797dbf
nothing to commit, working directory clean
remotes pre pre-authorized remote url
old git://github.com/medevice-users/gallery.git (fetch)
old git://github.com/medevice-users/gallery.git (push)
travis_fold:end:before_script.2
$ docpad deploy-ghpages
�[32minfo:�[39m Welcome to DocPad v6.46.4
�[32minfo:�[39m Contribute: http://docpad.org/docs/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.
Run
git config --global user.email "[email protected]"
git config --global user.name "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:
Error:
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "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?:
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.
@balupton you might like this.