基於Travis CI實現 Gitbook在 Github 和 Coding 的同步部署
前言
最近發現自己的部落格在使用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
配置後於是在阿里雲的域名解析上新增兩條CNAME記錄指向 hanyajun0123.coding.me,選擇預設解析,原來github的解析換成國外的dns解析路線,這樣國內的就指向coding,國外的指向github.io 訪問的時候出現了下面的這種異常(您的連結不是私密連結) 看了下coding的證書申請情況也是一直失敗 後來查了下資料發現得先暫停掉原先指向github.io的解析,這個會對與coding page進行校驗。後來停掉再次申請ssl證書就成功了,本來以為完美解決了,誰知自己部署在github page的gitbook的專案訪問不了,翻牆之後就可以訪問了,這個很好解釋,不翻牆就解析到了coding上。於是自己又琢磨了下如何基於travis ci實現gitbook在github和coding的自動化ci。如果之前沒有嘗試過使用travis ci來部署gitbo的可以參考下我之前寫的一篇部落格《如何使用travis-ci自動化構建部署GitHub Pages(gitbook)》
CI流程
獲取coding訪問令牌
travis新增coding token環境變數
在Travis上原來github部署ci的gitbook專案裡面新增訪問coding token。
修改.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
觸發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自動部署Hexo到github和codingHexoGithub
- 【Hexo】使用Hexo+github pages+travis ci 實現自動化部署HexoGithub
- 解放雙手,基於github travis-ci docker自動化部署java專案GithubDockerJava
- 用 Travis CI 打造大前端持續整合和自動化部署前端
- 基於rust實現的事件系統,支援同步和非同步Rust事件非同步
- 利用 GitHub 以及 Travis-CI 展示帶自己域名的 Vue 頁面GithubVue
- 基於OpenStack+Docker設計與實現CI/CD——基於Docker技術的CI&CD實踐Docker
- 把部落格同時部署到github和coding上Github
- Hexo部落格遷移之旅(Coding到騰訊雲COS)+ Travis CI持續整合Hexo
- 基於Travis CI搭建Android自動打包釋出工作流Android
- 基於YARP實現的FastGithubASTGithub
- Golang基於Gitlab CI/CD部署方案GolangGitlab
- `GitHub page` 和 `gitbook` 結合使用Github
- 如何將gitbook和github關聯?Github
- Travis + github page 前端頁面自動化部署Github前端
- 基於 GitLab CI 的前端工程CI/CD實踐Gitlab前端
- 使用github+travis將Python包部署到PypiGithubPython
- 同時在GitHub和Coding上搭建Hexo部落格GithubHexo
- 使用 GitHub 和 Python 實現持續部署GithubPython
- 聯調環境快速部署——基於docker-compose的CI/CD實踐Docker
- 前端專案基於GitLab-CI的持續整合/持續部署(CI/CD)前端Gitlab
- 使用GitHub Actions和GitHub pages實現前端專案的自動打包部署Github前端
- 拯救懶癌文件君 - VuePress + Travis CI + Github Pages 自動線上生成文件VueGithub
- Travis CI:最小的分散式系統(上)分散式
- 通過travis自動部署hexo部落格到github pagesHexoGithub
- 將 Hexo 個人部落格同時部署到 GitHub 和 Coding 上HexoGithub
- 基於Guava API實現非同步通知和事件回撥GuavaAPI非同步事件
- 前端測試簡述及使用Karma/Mocha實現的整合測試栗子(Travis CI/Coverage)前端
- Travis-CI自動化測試並部署至自己的CentOS伺服器CentOS伺服器
- Travis CI 配置檔案 .travis.yml 的語法介紹和一些用法舉例
- 基於github的CICD實踐Github
- 基於 Redis 的方式實現非同步佇列Redis非同步佇列
- 基於Drone實現CI/CD【0到1架構系列】架構
- 基於nginx和uWSGI在Ubuntu上部署DjangoNginxUbuntuDjango
- 持續整合服務 Travis CI 教程
- 為Github倉庫新增Github Actions實現持續整合: Android apk自動編譯釋出以及github pages同步推送coding.netGithubAndroidAPK編譯
- 基於 swoole 的 websocket 服務實現狀態同步Web
- 基於RabbitMQRPC實現的主機非同步管理MQRPC非同步