This project explains how to manipulate a Git repository within Travis CI to publish a static site build with Hugo on GitHub Page.
Adding a new SSH key to your GitHub account
In this case you can assume to don't define a passphrase for the SSH key.
Encrypt SSH key:
- https://docs.travis-ci.com/user/encrypting-files/
- https://github.com/travis-ci/travis.rb#encrypt-file
Get a Personal Access Token.
Only enable public_repo
access for public repositories, repo
for private.
Save the token somewhere as you can only see it once.
See publish.sh
- Custom Deployment: Git
- Security information: Security-Restrictions-when-testing-Pull-Requests
Travis automatically skips the build if the commit contains [ci skip]
.
Example:
git commit -m 'My commit message [ci skip]'
You can skip build by defined `` variable.
Install Hugo
git init travis-continuous-delivery-hugo-publish
cd travis-continuous-delivery-hugo-publish
git checkout -b source
cd ..
hugo new site travis-continuous-delivery-hugo-publish --force
cd travis-continuous-delivery-hugo-publish
hugo new post/first-post.md
echo 'Some text.' >> content/post/first-post.md
You must defined environement variables via Travis:
USER_EMAIL
: Git user emailUSER_NAME
: Git user name