Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

initial commit. yay.

  • Loading branch information...
commit a04d26ca8ee67d6336e0f202df69850f1171d311 0 parents
Nick Gauthier authored March 14, 2012
39  README.md
Source Rendered
... ...
@@ -0,0 +1,39 @@
  1
+# Deploy from Github to Heroku with Hubot
  2
+
  3
+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!
  4
+
  5
+## Usage
  6
+
  7
+### 1. Copy
  8
+
  9
+Copy the `git-across.sh` file to the root of your hubot. Copy `github-to-heroku.coffee` to your `scripts` folder in your hubot.
  10
+
  11
+
  12
+### 2. Auth
  13
+
  14
+Generate a key with `ssh-keygen`.
  15
+
  16
+Upload it to github under your project's Deploy Key field.
  17
+
  18
+We'll call this `my-github-deploy-ssh-key` from now on.
  19
+
  20
+Send the public key to heroku:
  21
+
  22
+    heroku keys:add my-github-deploy-ssh-key.pub
  23
+
  24
+### 3. Config
  25
+
  26
+Export the following config vars to heroku:
  27
+
  28
+    GITHUB_KEY="`cat my-github-deploy-ssh-key`"
  29
+    GITHUB_PUBLIC_KEY="`cat my-github-deploy-ssh-key.pub`"
  30
+    GITHUB_URL="git@github.com:myproject/myrepo.git"
  31
+    HEROKU_URL="git@heroku.com:myherokurepo.git"
  32
+
  33
+### 4. Deploy and Use
  34
+
  35
+Commit the script changes to your hubot and push him to heroku. Then, in campfire:
  36
+
  37
+    hubot deploy
  38
+
  39
+Tada!
30  git-across.sh
... ...
@@ -0,0 +1,30 @@
  1
+#!/bin/sh
  2
+
  3
+if [ "run" != "$1" ]; then
  4
+  exec ssh -i "$IDENTITY_FILE" -o "StrictHostKeyChecking no" "$@"
  5
+fi
  6
+
  7
+echo "Deploying from $GITHUB_URL to $HEROKU_URL"
  8
+
  9
+self="$( cd "$( dirname "$0" )" && pwd )"/$0
  10
+
  11
+export IDENTITY_FILE="`mktemp /tmp/tmp.XXXXXXXXXX`"
  12
+export GIT_SSH="$self"
  13
+
  14
+repo=`mktemp -d /tmp/tmp.XXXXXXXXXX`
  15
+
  16
+echo "$GITHUB_KEY" >"$IDENTITY_FILE"
  17
+echo "$GITHUB_PUBLIC_KEY" >"$IDENTITY_FILE.pub"
  18
+
  19
+
  20
+git clone $GITHUB_URL $repo
  21
+cd $repo
  22
+git remote add heroku $HEROKU_URL
  23
+git push heroku
  24
+
  25
+rm -f "$IDENTITY_FILE"
  26
+rm -f "$IDENTITY_FILE.pub"
  27
+rm -rf $repo
  28
+
  29
+exit 0
  30
+
9  github-to-heroku.coffee
... ...
@@ -0,0 +1,9 @@
  1
+cp = require('child_process');
  2
+
  3
+module.exports = (robot) ->
  4
+  robot.respond /deploy/i, (msg) ->
  5
+    deploy = cp.spawn('./git-across.sh', ['run'])
  6
+    emit = (data) ->
  7
+      msg.send(m) for m in data.toString().split("\n") when m.length > 0
  8
+    deploy.stdout.on('data', emit)
  9
+    deploy.stderr.on('data', emit)

0 notes on commit a04d26c

Please sign in to comment.
Something went wrong with that request. Please try again.