美文网首页
基于Travis CI实现 Gitbook在 Github 和

基于Travis CI实现 Gitbook在 Github 和

作者: 朗月清风hyj | 来源:发表于2019-05-18 00:55 被阅读0次

    前言

    最近发现自己的博客在使用vpn的情况下打开很慢,百度站点也抓取失败,于是将自己的博客借助hexo-deploy 插件很容易同步部署到了coding上。只需要在你的hexo配置文件_config.yml的deploy配上coding的coding page项目url(注意将ssh key 设置好)

    deploy:
    - type: git
      repository: 
        - git@github.com:Han-Ya-Jun/Han-Ya-Jun.github.io.git
        - git@git.dev.tencent.com:hanyajun0123/hanyajun0123.git
      branch: master
      message: update
    - type: baidu_url_submitter
    
    image

    配置后于是在阿里云的域名解析上新增两条CNAME记录指向 hanyajun0123.coding.me,选择默认解析,原来github的解析换成国外的dns解析路线,这样国内的就指向coding,国外的指向github.io

    image
    访问的时候出现了下面的这种异常(您的链接不是私密链接)
    image
    看了下coding的证书申请情况也是一直失败
    image
    后来查了下资料发现得先暂停掉原先指向github.io的解析,这个会对与coding page进行校验。后来停掉再次申请ssl证书就成功了,本来以为完美解决了,谁知自己部署在github page的gitbook的项目访问不了,翻墙之后就可以访问了,这个很好解释,不翻墙就解析到了coding上。于是自己又琢磨了下如何基于travis ci实现gitbook在github和coding的自动化ci。如果之前没有尝试过使用travis ci来部署gitbo的可以参考下我之前写的一篇博客《如何使用travis-ci自动化构建部署GitHub Pages(gitbook)》

    CI流程

    image

    获取coding访问令牌

    image

    travis添加coding token环境变量

    在Travis上原来github部署ci的gitbook项目里面添加访问coding token。


    image

    修改.travis.yaml 文件

    after_script:
       - cd ./_book
       - git init
       - git config user.name "*****" 
       - git config user.email "******"
       - git add .
       - git commit -m "Update Gitbook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
       - git push --force --quiet "https://hanyajun0123:${CODING_TOKEN}@${CO_REF}" master:master
       - git tag v0.0.$TRAVIS_BUILD_NUMBER -a -m "Auto Taged By TravisCI With Build $TRAVIS_BUILD_NUMBER"
       - git push --quiet "https://hanyajun0123:${CODING_TOKEN}@${CO_REF}" master:master --tags
    
    # git@git.dev.tencent.com:hanyajun0123/coding_basis_review.git
    env:
     global:
       # Coding Pages
       - CO_REF: git.dev.tencent.com/hanyajun0123/coding_basis_review.git
    

    完整.travis.yaml文件

    触发ci

    修改本地gitbook项目,推送到github上去,就可以粗发ci了。

    Creating a brand new local repo from scratch in dir /tmp/d20190517-7047-qvpbfn/work...
    dpl.2
    Preparing deploy
    dpl.3
    Deploying application
    Initialized empty Git repository in /tmp/d20190517-7047-qvpbfn/work/.git/
    Repo created successfully
    Switched to a new branch 'gh-pages'
    An orphan branch gh-pages created successfully
    cd -
    cd /tmp/d20190517-7047-qvpbfn/work
    Copying /home/travis/build/Han-Ya-Jun/coding_basis_review/_book contents to /tmp/d20190517-7047-qvpbfn/work (workdir: /tmp/d20190517-7047-qvpbfn/work)...
    Configuring git committer to be Deployment Bot (from Travis CI) <deploy@travis-ci.org> (workdir: /tmp/d20190517-7047-qvpbfn/work)
    Preparing to deploy gh-pages branch to gh-pages (workdir: /tmp/d20190517-7047-qvpbfn/work)
    commit 76413d48b1f036c4b9c9b4e3fbad583fa24aa87a
    Author: Deployment Bot (from Travis CI) <deploy@travis-ci.org>
    Date:   Fri May 17 01:15:08 2019 +0800
        Deploy Han-Ya-Jun/coding_basis_review to github.com/Han-Ya-Jun/coding_basis_review.git:gh-pages
     .travis.yml                                        |  49 ++
     generation                                         |   0
     gitbook/fonts/fontawesome/FontAwesome.otf          | Bin 0 -> 124988 bytes
     gitbook/fonts/fontawesome/fontawesome-webfont.eot  | Bin 0 -> 76518 bytes
     gitbook/fonts/fontawesome/fontawesome-webfont.svg  | 685 +++++++++++++++++++++
     gitbook/fonts/fontawesome/fontawesome-webfont.ttf  | Bin 0 -> 152796 bytes
     gitbook/fonts/fontawesome/fontawesome-webfont.woff | Bin 0 -> 90412 bytes
     .../fonts/fontawesome/fontawesome-webfont.woff2    | Bin 0 -> 71896 bytes
     gitbook/gitbook-plugin-3-ba/plugin.js              |  20 +
     .../gitbook-plugin-back-to-top-button/plugin.css   |  55 ++
     ...
     51 files changed, 6434 insertions(+)
    Doing the git push (workdir: /tmp/d20190517-7047-qvpbfn/work)...
    On branch gh-pages
    nothing to commit, working tree clean
    cd -
    App has been pushed
    after_script.1
    0.01s$ cd ./_book
    after_script.2
    0.01s$ git init
    Initialized empty Git repository in /home/travis/build/Han-Ya-Jun/coding_basis_review/_book/.git/
    after_script.3
    0.01s$ git config user.name "hanyajun0123"
    after_script.4
    0.01s$ git config user.email "1581532052@qq.com"
    after_script.5
    0.05s$ git add .
    after_script.6
    0.02s$ git commit -m "Update Gitbook By TravisCI With Build $TRAVIS_BUILD_NUMBER"
    [master (root-commit) 1c86337] Update Gitbook By TravisCI With Build 10
     51 files changed, 6434 insertions(+)
     create mode 100644 .travis.yml
     create mode 100644 generation
     create mode 100644 gitbook/fonts/fontawesome/FontAwesome.otf
     create mode 100644 gitbook/fonts/fontawesome/fontawesome-webfont.eot
     create mode 100644 gitbook/fonts/fontawesome/fontawesome-webfont.svg
     create mode 100644 gitbook/fonts/fontawesome/fontawesome-webfont.ttf
     create mode 100644 gitbook/fonts/fontawesome/fontawesome-webfont.woff
     create mode 100644 gitbook/fonts/fontawesome/fontawesome-webfont.woff2
     create mode 100644 gitbook/gitbook-plugin-3-ba/plugin.js
     create mode 100644 gitbook/gitbook-plugin-back-to-top-button/plugin.css
     create mode 100644 gitbook/gitbook-plugin-back-to-top-button/plugin.js
     create mode 100644 gitbook/gitbook-plugin-disqus/plugin.css
     create mode 100644 gitbook/gitbook-plugin-disqus/plugin.js
     create mode 100644 gitbook/gitbook-plugin-donate/plugin.css
     create mode 100644 gitbook/gitbook-plugin-donate/plugin.js
     create mode 100644 gitbook/gitbook-plugin-editlink/plugin.js
     create mode 100644 gitbook/gitbook-plugin-fontsettings/fontsettings.js
     create mode 100644 gitbook/gitbook-plugin-fontsettings/website.css
     create mode 100644 gitbook/gitbook-plugin-ga/plugin.js
     create mode 100644 gitbook/gitbook-plugin-github-buttons/plugin.js
     create mode 100644 gitbook/gitbook-plugin-github-buttons/plugin.js.map
     create mode 100644 gitbook/gitbook-plugin-github/plugin.js
     create mode 100644 gitbook/gitbook-plugin-image-captions/image-captions.css
     create mode 100644 gitbook/gitbook-plugin-page-toc-button/plugin.css
     create mode 100644 gitbook/gitbook-plugin-page-toc-button/plugin.js
     create mode 100644 gitbook/gitbook-plugin-prism/prism-coy.css
     create mode 100644 gitbook/gitbook-plugin-prism/prism-dark.css
     create mode 100644 gitbook/gitbook-plugin-prism/prism-funky.css
     create mode 100644 gitbook/gitbook-plugin-prism/prism-okaidia.css
     create mode 100644 gitbook/gitbook-plugin-prism/prism-solarizedlight.css
     create mode 100644 gitbook/gitbook-plugin-prism/prism-tomorrow.css
     create mode 100644 gitbook/gitbook-plugin-prism/prism-twilight.css
     create mode 100644 gitbook/gitbook-plugin-prism/prism.css
     create mode 100644 gitbook/gitbook-plugin-search-plus/jquery.mark.min.js
     create mode 100644 gitbook/gitbook-plugin-search-plus/search.css
     create mode 100644 gitbook/gitbook-plugin-search-plus/search.js
     create mode 100644 gitbook/gitbook-plugin-sharing/buttons.js
     create mode 100644 gitbook/gitbook-plugin-splitter/splitter.css
     create mode 100644 gitbook/gitbook-plugin-splitter/splitter.js
     create mode 100644 gitbook/gitbook-plugin-tbfed-pagefooter/footer.css
     create mode 100644 gitbook/gitbook.js
     create mode 100644 gitbook/images/apple-touch-icon-precomposed-152.png
     create mode 100644 gitbook/images/favicon.ico
     create mode 100644 gitbook/style.css
     create mode 100644 gitbook/theme.js
     create mode 100644 index.html
     create mode 100644 network/TCP_IP.html
     create mode 100644 network/summary.html
     create mode 100644 package-lock.json
     create mode 100644 search_plus_index.json
     create mode 100644 sitemap.xml
    after_script.7
    3.87s$ git push --force --quiet "https://hanyajun0123:${CODING_TOKEN}@${CO_REF}" master:master
    after_script.8
    0.01s$ git tag v0.0.$TRAVIS_BUILD_NUMBER -a -m "Auto Taged By TravisCI With Build $TRAVIS_BUILD_NUMBER"
    after_script.9
    1.65s$ git push --quiet "https://hanyajun0123:${CODING_TOKEN}@${CO_REF}" master:master --tags
    Done. Your build exited with 0.
    

    相关文章

      网友评论

          本文标题:基于Travis CI实现 Gitbook在 Github 和

          本文链接:https://www.haomeiwen.com/subject/swqzaqtx.html