mmb/meme_captain_web

View on GitHub
bin/shipit

Summary

Maintainability
Test Coverage
#!/bin/bash

set -e
set -o pipefail

CURRENT_BRANCH=$(git symbolic-ref --short HEAD)
if [ "$CURRENT_BRANCH" != "master" ]; then
  echo 'The current branch must be master'
  exit 1
fi

RAILS_ENV=test bundle exec rake spec:all

if [ "$(git log @{u}.. | wc -l)" -ne "0" ]; then
  git push

  echo 'Waiting for Travis build to start'
  set +e
  SLEPT_FOR=0
  until travis status | grep start; do
    sleep 5
    SLEPT_FOR=$((SLEPT_FOR + 5))
    if [ $SLEPT_FOR -ge 120 ]; then exit 1; fi
  done

  echo 'Waiting for Travis build to pass'
  SLEPT_FOR=0
  until travis status --fail-pending --no-exit-code; do
    sleep 10
    SLEPT_FOR=$((SLEPT_FOR + 10))
    if [ $SLEPT_FOR -ge 1800 ]; then exit 1; fi
  done
  set -e

  # exit the script if the build failed
  travis status --exit-code
fi

# merge to deploy
git checkout deploy
git merge master
git push
git checkout master

pushd aws
packer build packer.json | tee /tmp/packer.log
AMI=$(tail -1 /tmp/packer.log | cut -d ' ' -f 2)
./deploy.sh $AMI
./ami_cleanup.sh
popd