This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

initial commit. yay.

  • Loading branch information...
0 parents commit a04d26ca8ee67d6336e0f202df69850f1171d311 @ngauthier committed Mar 14, 2012
Showing with 78 additions and 0 deletions.
  1. +39 −0 README.md
  2. +30 −0 git-across.sh
  3. +9 −0 github-to-heroku.coffee
@@ -0,0 +1,39 @@
+# Deploy from Github to Heroku with Hubot
+
+NOTE WARNING DANGER ETC: You have to give heroku (via environment variables) your public and private github deploy key for the repository you're deploying. Make sure you understand that this means that heroku (themselves, or if their data is stolen) could access your github repo. OK? Proceed!
+
+## Usage
+
+### 1. Copy
+
+Copy the `git-across.sh` file to the root of your hubot. Copy `github-to-heroku.coffee` to your `scripts` folder in your hubot.
+
+
+### 2. Auth
+
+Generate a key with `ssh-keygen`.
+
+Upload it to github under your project's Deploy Key field.
+
+We'll call this `my-github-deploy-ssh-key` from now on.
+
+Send the public key to heroku:
+
+ heroku keys:add my-github-deploy-ssh-key.pub
+
+### 3. Config
+
+Export the following config vars to heroku:
+
+ GITHUB_KEY="`cat my-github-deploy-ssh-key`"
+ GITHUB_PUBLIC_KEY="`cat my-github-deploy-ssh-key.pub`"
+ GITHUB_URL="git@github.com:myproject/myrepo.git"
+ HEROKU_URL="git@heroku.com:myherokurepo.git"
+
+### 4. Deploy and Use
+
+Commit the script changes to your hubot and push him to heroku. Then, in campfire:
+
+ hubot deploy
+
+Tada!
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+if [ "run" != "$1" ]; then
+ exec ssh -i "$IDENTITY_FILE" -o "StrictHostKeyChecking no" "$@"
+fi
+
+echo "Deploying from $GITHUB_URL to $HEROKU_URL"
+
+self="$( cd "$( dirname "$0" )" && pwd )"/$0
+
+export IDENTITY_FILE="`mktemp /tmp/tmp.XXXXXXXXXX`"
+export GIT_SSH="$self"
+
+repo=`mktemp -d /tmp/tmp.XXXXXXXXXX`
+
+echo "$GITHUB_KEY" >"$IDENTITY_FILE"
+echo "$GITHUB_PUBLIC_KEY" >"$IDENTITY_FILE.pub"
+
+
+git clone $GITHUB_URL $repo
+cd $repo
+git remote add heroku $HEROKU_URL
+git push heroku
+
+rm -f "$IDENTITY_FILE"
+rm -f "$IDENTITY_FILE.pub"
+rm -rf $repo
+
+exit 0
+
@@ -0,0 +1,9 @@
+cp = require('child_process');
+
+module.exports = (robot) ->
+ robot.respond /deploy/i, (msg) ->
+ deploy = cp.spawn('./git-across.sh', ['run'])
+ emit = (data) ->
+ msg.send(m) for m in data.toString().split("\n") when m.length > 0
+ deploy.stdout.on('data', emit)
+ deploy.stderr.on('data', emit)

0 comments on commit a04d26c

Please sign in to comment.