Files
openfoodnetwork/script/ci/push_to_production.sh
Maikel Linke 2357f46a4e CI scripts use env vars
The CI scripts are configurable through the environment. They had
hardcoded configurations before. The Australian BuildKite setup will
need global environment variables like this:

STAGING_SSH_HOST=ofn-staging2
STAGING_CURRENT_PATH=/home/openfoodweb/apps/openfoodweb/current
STAGING_SERVICE=unicorn_openfoodweb
STAGING_DB_HOST=localhost
STAGING_DB_USER=openfoodweb
STAGING_DB=openfoodweb_production
PRODUCTION_REMOTE=production:/home/openfoodweb/apps/openfoodweb/current
2015-10-21 10:04:29 +11:00

22 lines
818 B
Bash
Executable File

#!/bin/bash
set -e
source "`dirname $0`/includes.sh"
OFN_COMMIT=$(get_ofn_commit)
if [ "$OFN_COMMIT" = 'OFN_COMMIT_NOT_FOUND' ]; then
OFN_COMMIT=$(git rev-parse $BUILDKITE_COMMIT)
fi
echo "--- Checking environment variables"
require_env_vars OFN_COMMIT STAGING_SSH_HOST STAGING_CURRENT_PATH STAGING_SERVICE STAGING_DB_HOST STAGING_DB_USER STAGING_DB PRODUCTION_REMOTE
echo "--- Saving baseline data for staging"
VARS="CURRENT_PATH='$STAGING_CURRENT_PATH' SERVICE='$STAGING_SERVICE' DB_HOST='$STAGING_DB_HOST' DB_USER='$STAGING_DB_USER' DB='$STAGING_DB'"
ssh "$STAGING_SSH_HOST" "$VARS $STAGING_CURRENT_PATH/script/ci/save_staging_baseline.sh $OFN_COMMIT"
echo "--- Pushing to production"
exec 5>&1
OUTPUT=$(git push "$PRODUCTION_REMOTE" "$OFN_COMMIT":master --force 2>&1 |tee /dev/fd/5)
[[ $OUTPUT =~ "Done" ]]