The final step in this process is to automate the publishing process so each time you update your master branch on GitHub your website is automatically published to your GitHub.io page.
LOG IN USING GITHUB option.Create your first application button.In the Environment tab add the following variables:
| Key | Value | Protected |
|---|---|---|
| GIT_ACCOUNT | <github-username> | No |
| GIT_PROJECT | <github-username>/example-site.git | No |
| GIT_EMAIL | <your-github-email> | yes |
In a new tab, go to https://github.com/settings/tokens and click Generate new token.
Add “Wercker” to the note field and check the repo box under scopes. Then click Generate token.
Copy the generated token and go back to the Environment tab on the Wercker site.
Add a GIT_KEY key and paste your token from GitHub into the Value field. Select the Protected check-box and then click Add.
In a text editor, prepare the following files and save them to the example-site directory:
prep.sh:
#!/bin/bash
git worktree add -B gh-pages public origin/gh-pagesdeploy.sh:
#!/bin/bash
git config --global user.email "$GIT_EMAIL"
git config --global user.name "$GIT_ACCOUNT"
cd public
git add --all
git commit -m "Publishing to gh-pages"
cd ..
git push https://$GIT_ACCOUNT:$GIT_KEY@github.com/$GIT_PROJECT gh-pageswrecker.yml
box: debian
build:
steps:
- install-packages:
packages: git ssh-client
- script:
name: prep
code: bash prep.sh
- arjen/hugo-build:
version: "0.55.6"
theme: restaurant-hugo
config: config.toml
- script:
name: deploy
code: bash deploy.shThe prep.sh file is used to set up the public folder in the publishing process. The deploy.sh pushes the built site to the gh-pages branch. The wercker.yml ties everything together and tells the Wercker workflow how to walk through the steps.
Note: the deploy.sh file should use linux line endings. More details can be found here.
Add and commit these new files to your local repo:
git add .
git commit -m "Adding configuration files."Now push your changes up to GitHub and check https://app.wercker.com/ to see if your site builds:
git push origin masterOnce successfully built, the website should update a few minutes after each commit to the source content is made.