Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use github-services hook to post my feeds to other services?

Github has developed github-services hook to push commits to other services like bugzilla, campfire, basecamp ..

Can one use the same github-services hook to push my application data to other services? If yes how may I integrate github-services to my Rails application.

Any Help ? Any suggestion ?

Update Can I integrate github-services hook source code as Sinatra application inside my Rails application ? How may I call other services(bugzilla, campfire, basecam, twitter) hooks from my application triggers ?

As example, When one user post something on other user's wall than message should be sent to the other services like bugzilla,campfire,basecamp, twitter ...

like image 512
krunal shah Avatar asked Feb 23 '23 01:02

krunal shah


2 Answers

The Post-Receive Url is the simplest hook to perform such notification. It triggers a POST to a pre-configured Url whenever a pushis performed on the repository.

You could start with this Github.help page on testing web hooks to understand the format of what is being POSTed and how the service reacts. This is done thanks a very useful service: PostBin.

This help page gives a simple example of what one would have to implement on a Sinatra server to parse the POSTed JSON:

post '/' do
    push = JSON.parse(params[:payload])
    "I got some JSON: #{push.inspect}"
end

This gist goes a little further and show some really basic JSON data extraction.

If you want to go further, you can configure, through the GitHub API, some additional hooks to listen to more events (new issue, new fork, download, ...).

like image 189
nulltoken Avatar answered Mar 05 '23 17:03

nulltoken


I think you are looking for an easy way to post your app's data to many other web services.

github-services is designed to take git commit information and push it to other services that accept that commit information... so if your app's data looks enough like github's payload, then those other services that work with github-services will work with your app.

But I suspect your app is not like github and your data is different than a git commit. In that case, you could make use of the code in 'services/' as examples of how to implement event handlers in your app. This one for Campfire uses the Tinder gem, for example: https://github.com/github/github-services/blob/master/services/campfire.rb

Then your WallPostsController#create could call a method that posts data in the format you choose to the various services. If you're going to post to many services, you may want to do it in an asynchronous job (DelayedJob, resque, etc.) because calls to many external services will take quite a while.

like image 39
rkb Avatar answered Mar 05 '23 16:03

rkb