mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
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
22 lines
818 B
Bash
Executable File
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" ]]
|