On change update setup
On change update setup
Inspiration for the website is http://twitter.github.io/ or http://hadley.github.io/. Problem with those websites is they use the Github API anonymously. Which is limited to 60 requests an hour.
A solution to this is to perform builds when a repo of the Github organization changes.
Note: Below was never completly tested.
TODO try zapier instead of ifttt.
- Use Github webhooks in repositories to trigger when something changes.
- Webhook urls are listened on a IFTT recipe using it’s Maker channel (https://github.com/captn3m0/ifttt-webhook)
- The IFTT recipy triggers a Travis-CI build (https://docs.travis-ci.com/user/triggering-builds)
- The Travis-CI build will fetch data using Github API and write/commit/push the results as a json file.
- Github Pages will host this new json file.
- Site visitors will see up 2 date data.
Cons:
- Unable to trigger travis-CI build from IFTTT, because unable to pass auth header
- Setting up all the webhooks is a lot of work Pros:
- Wait a day for stats to update
Setup IFFTTT Maker endpoint
- Login to https://ifttt.com/
- Goto https://ifttt.com/maker
- Click on
How to Trigger Events
- Replace
{event}
by organization name. - Store the url for later
The url will be https://maker.ifttt.com/trigger/<organization name>/with/key/<IFTTT Maker key>
Setup Github webhooks
Foreach repository in the Github Organization create a webhook in the repo settings.
- Payload URL = IFFTTT Maker endpoint
- Which events would you like to trigger this webhook? = Let me select individual events.
- Select the following events
- Push
- Issues
- Fork
- Watch
- Release
Github key for Travis-CI
To commit and push in Travis-CI we need a .
- Generate a ssh key pair
ssh-keygen -t rsa -f travis-ci.key -P '' -C '<organization name>@travis-ci'
This will generate
- travis-ci.key.pub, use as Github deploy key
- travis-ci.key, use in Travis-CI job
- Goto
https://github.com/<organization name>/<organization name>.github.io/settings/keys
- Add deploy key
- Title = Travis-CI json update
- Key =
<content of travis-ci.key.pub>
- Check Allow write access
- Press
Add key
button
Setup Travis-CI
- Goto
https://travis-ci.org/profile/<project name>
. - Activate Travis-CI for
<project name>.github.io
repo. - Goto settings of
<project name>.github.io
repo. - Turn off
Build pushes
- Turn off
Build pull requests
- Add Github deploy key to environment variable.
- Key = DEPLOY_KEY
- Value =
<content of travis-ci.key>
- Display value = turned off
To trigger a build a Travis-CI token is required. This can be found on https://travis-ci.org/profile/ page. Click on the eye icon next to ‘Token’ to get your token.
Generate Travis-CI token
docker run --rm -ti ruby:2.1.3 bash
gem install travis -v 1.8.2 --no-rdoc --no-ri
travis login --org
travis token
Listen for Github webhook using IFTTT recipe and trigger Travis-CI build
Goto https://ifttt.com/myrecipes/personal/new
- Select ‘this’
- Filter on ‘Maker’
- Select ‘Maker’ channel
- Select ‘Receive a web request’
- Set Event Name = organization name (eg. 3D-e-Chem)
- Select ‘that’
- Filter on ‘Maker’
- Select ‘Maker’ channel
- Select ‘Make a web request’
- URL = https://api.travis-ci.org/repo/
%2F .github.io/requests (eg. https://api.travis-ci.org/repositories/3D-e-Chem%2f3D-e-Chem.github.io/requests) - Method = POST
- Content Type = application/json
- Body =
{
"request": {
"branch": "master",
"token": "<Travis-CI token>"
}
}
- Recipe title = Trigger Travis-CI build of
.github.io Github repo on any repo change. - Disable
Recieve notifiactions
- Press
Create recipe
button