master: 博客的静态文件,也就是 hexo 生成后的 HTML 文件,因为要使用 Gitpage 服务,所以他规定的网页文件必须是在 master 分支
建新的分支 :dev :存放博客的源代码
Git 怎么推送本地分支到远程新分支上面去?
git push --force origin local_branch:remote_branch
这个操作, local_branch 必须为你本地存在的分支, remote_branch 为远程分支,如果 remote_branch 不存在则会自动创建分支。
类似, git push origin :remote_branch,local_branch 留空的话则是删除远程 remote_branch 分支。
$ git push origin --delete [branch-name]$ git branch -dr [remote/branch]
然后点击设置按钮,在项目的设置中开启 Build only if .travis.yml is present 这一项.

到这一步, 我们已经开启了要构建的仓库
首先我们来到 github 的设置界面,点击到 Personal access tokens 页面,点击右上角的 Generate new token 按钮会重新生成一个,点击后他会叫你输入密码,然后来到如下界面,给他去一个名字,下面是勾选一些权限

生成完后,你需要拷贝下来,接下来要用到
配置界面还是在项目的 setting 里面,如下图

还需要在源代码的仓库里创建一个 .travis.yml 配置文件,放到源代码的根目录,如下图
其中内容如下:
language: node_jsnode_js: stable# S: Build Lifecycleinstall: - npm install#before_script: # - npm install -g gulpscript: - hexo gafter_script: - cd ./public - git init - git config user.name "lifengsofts" - git config user.email "lifengsofts@gmail.com" - git add . - git commit -m "Update docs" - git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:master# E: Build LifeCyclebranches: only: - blog-sourceenv: global: - GH_REF: github.com/lifengsofts/lifengsofts.github.io.git
其中给你需要更换的又 git config 后面的配置信息
GH_REF 的值更改为你的仓库地址
到这一步我们配置已经完成了
以下是自己在 Ubuntu 下写的一个很简单很简单的脚本,用来方便写作部署博客
push 本地的代码至远程仓库之后,在 https://travis-ci.org 后台查看相关情况。
下面是成功的结果:


