Skip to content

Instantly share code, notes, and snippets.

@alx
Created November 15, 2010 16:27
Show Gist options
  • Save alx/700547 to your computer and use it in GitHub Desktop.
Save alx/700547 to your computer and use it in GitHub Desktop.
jabber bot to deploy rails app
#!/usr/bin/env ruby
require 'rubygems'
require 'jabber/bot'
# Create a new bot
bot = Jabber::Bot.new({
:name => 'Git Rails Bot',
:jabber_id => 'cool-jabber-bot@email.com',
:password => 'same-password-everywhere',
:master => ["your-mail@is-funky.com"],
:is_public => true,
:status => 'Hello, I am Deploy Bot.',
:presence => :chat,
:priority => 10,
:silent => true,
:debug => true
})
bot.add_command(
:syntax => 'pull <branch>',
:description => 'pull branch',
:regex => /^pull\s+.+$/
) do |sender, message|
system "cd /var/app/dedi1/current; git pull origin #{message}"
end
bot.add_command(
:syntax => 'restart',
:description => 'restart app',
:regex => /^restart$/
) do |sender, message|
system "touch /var/app/dedi1/current/tmp/restart.txt"
end
# Unleash the bot
bot.connect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment