These are some useful git commands for implementing this in your own deployment setup.
Detecting if we're running on a clean checkout:
- git fetch
- git diff --shortstat [branch]
Determining if there are pending migrations:
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations) | |
# By Peter Cooper | |
# Ruby 1.8.7/MagLev version by Karl Matthias | |
# | |
# MIT license | |
# | |
# * Not advised to use in your production environment! ;-) | |
# * Supports A and CNAME records | |
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance | |
# * All records get the same TTL |
class CaptureIO | |
# Coffeescript port of: https://gist.github.com/729616 | |
# | |
# Usage: | |
# test = new CaptureIO() | |
# unhook = test.hookStdout((string, encoding, fd) -> | |
# util.debug('stdout: ' + util.inspect(string)) | |
# ) | |
# Restoring stdout: |
Host * | |
ServerAliveInterval 10 | |
ServerAliveCountMax 600 |
kmatthias-mbp:dockercon kmatthias$ bundle exec centurion -p test -e production -a deploy | |
** Invoke environment:production (first_time) | |
** Invoke environment:common (first_time) | |
** Execute environment:common | |
** Execute environment:production | |
** Invoke deploy (first_time) | |
** Execute deploy | |
** Invoke deploy:get_image (first_time) | |
** Execute deploy:get_image | |
** Invoke deploy:pull_image (first_time) |
The following code run from inside a Ruby script that has loaded the etcd
gem would create the necessary
keys to deploy using the above code.
client.set('/services/fooservice/ports/3021', value: 9292)
client.set('/services/fooservice/env/TESTING_URL', value: 'http//foo.example.com/asdf')
client.set('/services/fooservice/ports/3021', value: 9292) | |
client.set('/services/fooservice/env/TESTING_URL', value: 'http//foo.com/asdf') | |
client.set('/services/fooservice/hosts/chi-staging-foo-1.nr-ops.net', value: 'up') | |
client.set('/services/fooservice/hosts/chi-staging-foo-2.nr-ops.net', value: 'up') | |
client.set('/services/fooservice/hosts/chi-staging-foo-3.nr-ops.net', value: 'down') | |
client.set('/services/fooservice/endpoints/chi-staging-foo-1.nr-ops.net', value: 'http://chi-staging-foo-1.nr-ops.net:3021/') | |
client.set('/services/fooservice/endpoints/chi-staging-foo-2.nr-ops.net', value: 'http://chi-staging-foo-2.nr-ops.net:3021/') | |
client.set('/services/fooservice/endpoints/chi-staging-foo-3.nr-ops.net', value: 'http://chi-staging-foo-3.nr-ops.net:3021/') |
#!/bin/bash | |
REPOS="" | |
for config in `find . -maxdepth 3 -name config | grep '.git'`; do | |
egrep "github.com:newrelic|github.com/newrelic" $config > /dev/null | |
if [[ $? -eq 0 ]]; then | |
repo_dir=`dirname $(dirname ${config})` | |
REPOS="${REPOS} `basename ${repo_dir}`" | |
fi | |
done |