We are compiling Doxygen docs on the travis-ci server and want to push them onto our gh-pages branch.
How do I handle the authorization for git push? Do
I just wrote a blog about this some days ago. Here's the brief:
I wrote a custom deploy script for this purpose. The core functionality of the script looks like this:
#!/bin/bash
git clone --depth=1 --branch=master "https://github.com/iBug/iBug.github.io.git" deploy
cd deploy
git rm -rf .
cd ..
mv _site/* deploy
cd deploy
git add --all
git config user.name "Travis CI"
git config user.email "travis@travis-ci.org"
git commit --message "Auto deploy from Travis CI"
git remote add deploy "https://$GH_TOKEN@github.com/iBug/iBug.github.io.git" &>/dev/null
git push deploy master &>/dev/null
Now go to https://github.com/settings/tokens and generate a token. Grant it public_repo privilege. Go to repository settings on Travis CI and store the token with the variable name being GH_TOKEN.
Add the deploy script to travis:
script: bundle exec jekyll build
after_success:
- bash .travis/deploy.sh
Push these things to GitHub and Travis will be triggered.
My blog is here. It's comprehensive and thus redundant if posted as an answer here (because Stack Overflow users are mostly experienced developers). The script I posted in my blog also lacks a functionality: It does not preserve commit history of the built site, whereas the script in this answer above does.