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.

  1. Use Github webhooks in repositories to trigger when something changes.
  2. Webhook urls are listened on a IFTT recipe using it’s Maker channel (https://github.com/captn3m0/ifttt-webhook)
  3. The IFTT recipy triggers a Travis-CI build (https://docs.travis-ci.com/user/triggering-builds)
  4. The Travis-CI build will fetch data using Github API and write/commit/push the results as a json file.
  5. Github Pages will host this new json file.
  6. 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

  1. Login to https://ifttt.com/
  2. Goto https://ifttt.com/maker
  3. Click on How to Trigger Events
  4. Replace {event} by organization name.
  5. 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 .

  1. 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
  1. Goto https://github.com/<organization name>/<organization name>.github.io/settings/keys
  2. Add deploy key
  • Title = Travis-CI json update
  • Key = <content of travis-ci.key.pub>
  • Check Allow write access
  1. Press Add key button

Setup Travis-CI

  1. Goto https://travis-ci.org/profile/<project name>.
  2. Activate Travis-CI for <project name>.github.io repo.
  3. Goto settings of <project name>.github.io repo.
  4. Turn off Build pushes
  5. Turn off Build pull requests
  6. 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

  1. Select ‘this’
  2. Filter on ‘Maker’
  3. Select ‘Maker’ channel
  4. Select ‘Receive a web request’
  5. Set Event Name = organization name (eg. 3D-e-Chem)
  6. Select ‘that’
  7. Filter on ‘Maker’
  8. Select ‘Maker’ channel
  9. 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>"
  }
}
  1. Recipe title = Trigger Travis-CI build of .github.io Github repo on any repo change.
  2. Disable Recieve notifiactions
  3. Press Create recipe button