By Tim Krajcar - allegro@conmolto.org
This is a simple, easy-to-deploy Sinatra application that is designed to take post-push notifications from Github and log on to a MU* (designed for PennMUSH, but easily adapted to others) and notify a channel about the commit(s) that have been pushed.
Sample output:
- Install Ruby.
- Install bundler via
gem install bundler
if you don't already have it. - Download the latest package from https://github.com/tkrajcar/github-notify-mush/tarball/master and extract it somewhere.
- In that extracted directory, run
bundle install
to install Sinatra and dependencies. - Set up the MUSH-side player to login to -
@pcreate Gitbot=mypass
,@power *gitbot=cemit hide
(orcomm_all hide
on MUX), etc. - Set up the MUSH-side channel -
@chan/add Git
,@chan/on git=me gitbot
- Copy
config.rb.dist
toconfig.rb
, and edit it to have the correct parameters that you just set up. - Test and make sure everything's working by running the web app locally: run
ruby github-notify-mush.rb
and, in another window, runruby test.rb
(edittest.rb
if you aren't running it on localhost first!) If everything is working, the bot should log in and @cemit a few sample commit notices. If you don't see this, check the Sinatra window and look for exceptions, check your MUSH log files to see if it tried to connect, etc. - Deploy the Sinatra application to whatever webserver you want to use it on, run
test.rb
against the 'live' URL to make sure it works, and then log into Github, go to the repository you want to report commits to, go to 'Admin', go to 'Service Hooks', select 'Post-Receive URLs', and add your live URL. Hit 'Test Hook' and you should get notified! You can have multiple repositories hitting the same URL - the bot reports the repository name as part of its process.
This app works just fine on Heroku (that's where I run it). Since Heroku doesn't support non-Gitted files, you can't use config.rb, but the code looks for Heroku environment variables if present and uses those instead.
So, run this:
heroku config:add GITHUB_NOTIFY_HOST=mymush.com GITHUB_NOTIFY_PORT=4201 GITHUB_NOTIFY_CONNECT_STRING="ch GitBot mypass" GITHUB_NOTIFY_CHANNEL=Git
Then check with heroku config
and make sure everything's set.
I'm Rince @ M*U*S*H
and can be reached by email as well, and will be happy to help as time and energy allows if you have issues.
Copyright (c) 2011-2014 Tim Krajcar - allegro@conmolto.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.