Skip to content

Instantly share code, notes, and snippets.

@marsam
Last active December 20, 2015 01:09
Show Gist options
  • Select an option

  • Save marsam/6046600 to your computer and use it in GitHub Desktop.

Select an option

Save marsam/6046600 to your computer and use it in GitHub Desktop.
Hubot Cakefile for heroku
# vim: ai ts=2 sts=2 et sw=2
#
# # Hubot Cakefile
#
# Heroku init
#
# $ heroku create --stack cedar
# $ git push heroku master
# $ heroku ps:scale app=1
# $ heroku addons:add redistogo:nano
fs = require 'fs'
config = require './config.json'
exec = (require 'child_process').exec
task 'create', 'Create a hubot in the current directory', (options) ->
exec "hubot --create .", (error, stdout, stderr) ->
if error
console.log error.message
process.exit error.code
console.log stdout if stdout
task 'env', 'Reads config.json and update heroku', (options) ->
if config.env
vars = ("#{conf}=#{val}" for own conf, val of config.env).join(" ")
exec "heroku config:add #{vars}", (error, stdout, stderr) ->
if error
console.log error.message
process.exit error.code
console.log stdout if stdout
task 'deploy', 'Deploy to heroku', (options) ->
exec "git push heroku master", (error, stdout, stderr) ->
if error
console.log error.message
process.exit error.code
console.log stdout if stdout
console.log stderr if stderr # git sends the output to stderr
task 'configure', 'Configure hubot', (options) ->
console.log "Configuring hubot"
name = config.name || "Hubot"
alias = config.alias || "!"
adapter = config.adapter || "campfire"
procfile = "web: bin/hubot -a #{adapter} -n #{name} -l #{alias}"
fs.writeFile "Procfile", procfile, (error) ->
console.log error if error
if config.scripts
fs.writeFile "hubot-scripts.json", JSON.stringify(config.scripts), (error, data) ->
console.log error if error
# We remove "npm install" because heroku made this already.
exec "sed -i -e '/npm install/d' bin/hubot", (error, stdout, stderr) ->
console.log error.message if error
{
"name": "Batou",
"alias": "!",
"scripts": [
"ive.coffee",
"aww.coffee",
"brb.coffee",
"coin.coffee",
"cheer.coffee",
"beerme.coffee",
"dealwithit.coffee",
"calm-down.coffee",
"catfacts.coffee",
"ascii.coffee",
"gif-me.coffee",
"advice.coffee",
"google.coffee",
"applause.coffee",
"stallman.coffee",
"grumpycat.coffee",
"geocodeme.coffee",
"good-night.coffee",
"chuck-norris.coffee",
"go-for-it.coffee",
"hubotagainsthumanity.coffee",
"redis-brain.coffee",
"shipit.coffee"
],
"env": {
"HUBOT_CAMPFIRE_ACCOUNT": "yourcampfireaccount",
"HUBOT_CAMPFIRE_TOKEN": "yourcampfiretoken",
"HUBOT_CAMPFIRE_ROOMS": "comma,separated,list,of,rooms,to,join",
"HUBOT_HEROKU_URL": "http://rosemary-britches-123.herokuapp.com"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment