How to publish to Github Pages from Travis CI?

后端 未结 5 1535
野趣味
野趣味 2020-12-12 15:28

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

5条回答
  •  余生分开走
    2020-12-12 15:55

    I don't know how recent it is, but Travis now have a built-in deployment option, basically add to your travis file :

    deploy:
      provider: pages
      skip_cleanup: true
      local_dir: myfolder/  # or remove this line to upload from root of repo
      github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
      on:
        branch: master
    

    Make sure you don't have a .gitignore in the uploaded folder ; it only uploads non ignored files.

    See the online official doc from travis : https://docs.travis-ci.com/user/deployment/pages/

    There is no public key issue using "Repository Settings" approach, you generate a key in Github then copy paste it into secret/non visible fields of Travis.

    Upload history issue : Note that each upload crushes any previously uploaded data, without preserving history.

    • You can now (Nov 2017+) instead preserve history by adding a keep_history: true line

    • This may be desirable as these snapshot builds can be voluminous, and they are reproducible at will anyway (simply branch your depot back from the revision you want). Pointing to such artifacts is typically pointing to a last successful build of a snapshot.

    • However to trigger storage to a stable place, simply edit your travis to add flag :
      target_branch: Branch to push force to, defaults to gh-pages
      E.g target_branch : rc1.2

    And run it once before setting it back to snapshot mode.

    Another alternative that might be good for releases (I haven't personally tested though) is to publish to a Tag see : https://docs.travis-ci.com/user/deployment/releases/

提交回复
热议问题