Automatically deploy your Ink blog to GitHub pages wiht Travis CI
InkPaper is an static blog generator developed by Golang, No dependencies, Cross platform, Easy use, Fast build, Elegant theme. New to InkPaper? With Travis CI can solve the problem of automatic build and deployment, so that we can focus more on writing.
What is Travis CI?
Travis CI is a hosted, distributed continuous integration service used to build and test software projects hosted at GitHub. This means that you’d better host your static blog on GitHub Pages. When Travis CI has been activated for GitHub Pages repository, GitHub will notify it whenever new commits are pushed to that repository. It can also be configured to only run for specific branches, or branches whose names match a specific pattern. Travis CI will then check out the relevant branch and run the commands specified in .travis.yml, which usually build the software and run any automated tests, in this post we will use Travis CI to run
ink build and push to
GitHub Pages branch. When that process has completed, Travis notifies the developer(s) in the way it has been configured to do so.
Before starting, make sure that your static blog repository has two branches, one for
ink blog source files, and the other for
GitHub Pages files. For example, I created a branch named
blog-source to store my
ink blog source files, and a branch named
master to host
GitHub Pages files.
- Sign in to Travis CI with your GitHub account.
- Once you’re signed in, go to your profile page and enable Travis CI for the repository you want to build.
- Add the
Github Access Tokento your repository in Travis CI, which can be used to access the GitHub API. Thus, Travis CI can push the files which are generated by InkPaper to GitHub Pages branch.
- Add a
.travis.ymlfile to your repository to tell Travis CI what to build.
- Add the
.travis.ymlfile to git, commit and push, to trigger a Travis CI build.
When we complete a post, and then push it to Github, Travis CI wil do the rest things . All we need to do is focus on writing.
You can find all the code mentioned in the repository: https://github.com/shery15/blog
This work by shery is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.