Giter VIP home page Giter VIP logo

clabot's Introduction

clabot-boilerplate

This is a clabot boilerplate designed to be deployed on Heroku.

Requirements

You should have the following installed and set up.

Creating the Git Repository

Before we start you need to either fork this repository or create a new one based on this boilerplate.

Once you have that set up create a new heroku app in the newly created folder. (In case you aren't familiar with heroku workflows yet, read this tutorial)

heroku create

Configuration

All you have to do now is change the options object in clabot.js.

All of the options are described in the documentation, but I'll explain the most important ones.

token

This should be a valid GitHub oAuth token. You probably want to create a seperate github account for your bot, so this is what a command to get such a token would look like:

curl -u 'clabotusername' -d '{"scopes":["repo"],"note":"clabot"}' https://api.github.com/authorizations

Creating an OAuth token for command-line use

Rather than just pasting the raw token into the js file we'll set up a heroku environment variable.

heroku config:set GITHUB_TOKEN=thetoken

secrets

The secrets you provide when subscribing to GitHub's events. Organized in a user/repo way so you can vary secrets on a per repo basis.

In order to receive events from GitHub you have to subscribe. clabot will never push code to the repositories, but push access is required to be able to receive events from the GitHub API.

Note: There is no need for the GitHub account associated with the token to be the same you subscribe to these events with.

curl -u "clabotusername" -i https://api.github.com/hub -F "hub.mode=subscribe" -F "hub.topic=https://github.com/:user/:repo/events/pull_request" -F "hub.callback=http://your-clabot.herokuapp.com/notify" -F "hub.secret=supersecretrandomstring"

curl -u "clabotusername" -i https://api.github.com/hub -F "hub.mode=subscribe" -F "hub.topic=https://github.com/:user/:repo/events/issue_comment" -F "hub.callback=http://your-clabot.herokuapp.com/notify" -F "hub.secret=supersecretrandomstring"

Again we'll save those secrets as environment variables

heroku config:set HUB_SECRET=supersecretrandomstring

Note: You have to do both of the commands for every repository that should be observed. One command for pull requests and one for comments on those.

http://developer.github.com/v3/repos/hooks/#pubsubhubbub

getContractors

This is the most important part of clabot, because that's where you plug your data into it.

The getContractors method will be called with a callback as the first argument. Do whatever you need to get an array of signed GitHub usernames and call the callback with it.

This could look like this:

getContractors = function(callback) {
  fetchContractorsFromDatabase(function(err, res){
    if (err) {
      callback([])
    } else {
      calback(res.contractors)
    }
  });
};

Have a look at our sample-clabot to see how we have done it.

All the other options should be obvious, especially with the documentation at hand.

Deploy it to heroku

Once you have clabot configured you test that everything is fine locally.

npm install
foreman start

If this doesn't show errors push you code to heroku

git push heroku master

Success

Congratulations, after heroku has finished building the app clabot will answer your pull requests.

Questions, or just wanna hang out and chat about clabot?

Join our HipChat room

clabot's People

Contributors

boennemann avatar rjmackay avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.