Merge branch 'master' into require_standard_variant

This commit is contained in:
Rob Harrington
2015-04-22 10:58:43 +10:00
3 changed files with 26 additions and 1 deletions

View File

@@ -2,9 +2,14 @@
set -e
# Add production git remote if required
PROD_TEST=`git remote | grep -s 'production' || true`
if [[ "$PROD_TEST" != *production* ]]; then
git remote add production ubuntu@ofn-prod:apps/openfoodweb/current
fi
echo "--- Saving baseline data for staging"
ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/save_staging_baseline.sh $BUILDKITE_COMMIT"
echo "--- Pushing to production"
[[ $(git push production $BUILDKITE_COMMIT:master --force 2>&1) =~ "Done" ]]

View File

@@ -15,4 +15,4 @@ echo "--- Preparing test database"
bundle exec rake db:test:prepare
echo "--- Running tests"
bundle exec rspec spec
bundle exec rspec spec -f d

View File

@@ -0,0 +1,20 @@
#!/bin/bash
# Every time staging is deployed, we load a baseline data set before running the new code's
# migrations. This script saves a new baseline data set for that purpose.
# This script is called remotely on a push to production. We only want to save a new baseline
# if the code in staging is identical to that in production. To accomplish that, we take the
# production commit SHA as a parameter ($1) and only perform the save if the SHA matches the
# current code checked out.
set -e
cd /home/openfoodweb/apps/openfoodweb/current
if [[ `git rev-parse HEAD` == $1 ]]; then
mkdir -p db/backup
pg_dump -h localhost -U openfoodweb openfoodweb_production |gzip > db/backup/staging-baseline.sql.gz
echo "Staging baseline data saved."
else
echo "Staging SHA does not match production, we will not save staging baseline data."
fi