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 nightly builds of organization website.
- https://nightli.es/ will trigger travis-ci builds.
- The build will fetch stats 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 stats of at most a day old.
An alternative solution which monitors all organization repos for changes to trigger a build is documented in BUILD_ON_CHANGE.md.
- 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
The build will only be triggered by nightli.es.
To commit and push in Travis-CI we need a key pair.
The public key needs to be registered in the Github settings and the encrypted private key needs to added to the repo.
Generate a ssh key pair with
ssh-keygen -t rsa -f travis-ci.key -P '' -C '<organization name>@travis-ci.org'
This will generate
- travis-ci.key.pub, use as Github deploy key
- travis-ci.key, use in Travis-CI job
Add deploy key to Github repo containing the organization pages.
- Goto
https://github.com/<organization name>/<organization name>.github.io/settings/keys
- Add deploy key
- Title = Travis-CI build
- Key =
<content of travis-ci.key.pub>
- Check Allow write access
- Press
Add key
button
Use travis cli to encrypt travis-ci.key
file.
- Use travis cli from docker container
alias travis='docker run -it --rm -u $UID -v $PWD:/data -e TRAVIS_CONFIG_PATH=/data/.travis jamespamplin/alpine-travis-cli'
- Login with Github credentials
travis login
- Encrypt key
travis encrypt-file travis-ci.key
- Add printed openssl command to .travis.yml in before_install stage
- Add
travis-ci.key.enc
file to repo - Commit changes.
- Push changes.
Use the Travis-CI API to trigger a build (https://docs.travis-ci.com/user/triggering-builds). To Travis-CI API requires a token.
Token can be fetched using
travis token
Trigger build with
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token <travis-ci token>" \
-d "{ \"request\": { \"branch\": \"master\"}}" \
https://api.travis-ci.org/repo/<organization>%2F<organization name>.github.io/requests
Register repo on https://nightli.es/
- Goto https://nightli.es/
- Login
- On dashboard turn this repo ON
Now every night a Travis-CI build will be triggered which will update the stats.json file.