git - How to publish to Github Pages from Travis CI? -
we compiling doxygen docs on travis-ci server , want push them onto our gh-pages branch.
how handle authorization git push
? have example using encrypted variables in travis-ci? should go https authorization or ssh key?
step-by-step example https api token in environment variable
others have mentioned it, here goes more detailed procedure.
create separate repository website (optional). reduce likelihood overwrite main repository, , keep output files polluting it.
get personal access token under https://github.com/settings/tokens
only enable "public_repo" access public repositories, "repo" private.
save token somewhere can see once.
on travis settings repository
https://travis-ci.org/<me>/<myrepo>/settings
create environment variable:github_api_key=<token>
and make sure mark "display value in build log" "off".
this safe because authorized pushes see such environment variables, if malicious user tries make pull request string, variable won't there.
just make sure never, ever list environment variables on build!
add following
.travis.yml
:after_success: | if [ -n "$github_api_key" ]; cd "$travis_build_dir" # generates `web` directory containing website. make web cd web git init git checkout -b gh-pages git add . git -c user.name='travis' -c user.email='travis' commit -m init # make sure make output quiet, or else api token leak! # works because api key can replace password. git push -f -q https://<me>:$github_api_key@github.com/<me>/<myrepo>-gh-pages gh-pages &2>/dev/null cd "$travis_build_dir" fi
alternative travis encrypt method
explained in detail at: https://stackoverflow.com/a/33109519/895245
encrypt string github_api_key=<key>
travis
gem, , add .travis.yml
:
env: secure: <encrypted>
this has advantage not require using travis web interface, require using gem , more copy pasting.
Comments
Post a Comment