mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Store commit at start of build process and use it throughout
This commit is contained in:
@@ -19,6 +19,21 @@ function succeed_if_master_merged {
|
||||
fi
|
||||
}
|
||||
|
||||
function set_ofn_commit {
|
||||
echo "Setting commit to $1"
|
||||
buildkite-agent meta-data set "openfoodnetwork:git:commit" $1
|
||||
}
|
||||
|
||||
function get_ofn_commit {
|
||||
echo `git rev-parse $BUILDKITE_BRANCH`
|
||||
}
|
||||
|
||||
function checkout_ofn_commit {
|
||||
OFN_COMMIT=`buildkite-agent meta-data get "openfoodnetwork:git:commit"`
|
||||
echo "Checking out stored commit $OFN_COMMIT"
|
||||
git checkout -qf "$OFN_COMMIT"
|
||||
}
|
||||
|
||||
function drop_and_recreate_database {
|
||||
# Adapted from: http://stackoverflow.com/questions/12924466/capistrano-with-postgresql-error-database-is-being-accessed-by-other-users
|
||||
psql -U openfoodweb postgres <<EOF
|
||||
|
||||
@@ -4,6 +4,7 @@ set -e
|
||||
source ./script/ci/includes.sh
|
||||
|
||||
echo "--- Checking if master has already been merged"
|
||||
set_ofn_commit $BUILDKITE_COMMIT
|
||||
succeed_if_master_merged
|
||||
|
||||
echo "--- Merging master into this branch"
|
||||
@@ -12,3 +13,5 @@ git merge origin/$BUILDKITE_BRANCH
|
||||
git merge origin/master -m "Auto-merge from CI [skip ci]"
|
||||
git push origin $BUILDKITE_BRANCH
|
||||
git checkout origin/$BUILDKITE_BRANCH
|
||||
|
||||
set_ofn_commit `git rev-parse $BUILDKITE_BRANCH`
|
||||
|
||||
@@ -9,7 +9,7 @@ if [[ "$PROD_TEST" != *production* ]]; then
|
||||
fi
|
||||
|
||||
echo "--- Saving baseline data for staging"
|
||||
ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/ci/save_staging_baseline.sh $BUILDKITE_COMMIT"
|
||||
ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/ci/save_staging_baseline.sh `get_ofn_commit`"
|
||||
|
||||
echo "--- Pushing to production"
|
||||
[[ $(git push production $BUILDKITE_COMMIT:master --force 2>&1) =~ "Done" ]]
|
||||
[[ $(git push production `get_ofn_commit`:master --force 2>&1) =~ "Done" ]]
|
||||
|
||||
@@ -16,4 +16,4 @@ echo "--- Loading baseline data"
|
||||
ssh ofn-staging2 "/home/openfoodweb/apps/openfoodweb/current/script/ci/load_staging_baseline.sh"
|
||||
|
||||
echo "--- Pushing to staging"
|
||||
[[ $(git push staging2 $BUILDKITE_COMMIT:master --force 2>&1) =~ "Done" ]]
|
||||
[[ $(git push staging2 `get_ofn_commit`:master --force 2>&1) =~ "Done" ]]
|
||||
|
||||
@@ -5,6 +5,7 @@ set -e
|
||||
echo "--- Loading environment"
|
||||
source ./script/ci/includes.sh
|
||||
load_environment
|
||||
checkout_ofn_commit
|
||||
|
||||
echo "--- Verifying branch is based on current master"
|
||||
exit_unless_master_merged
|
||||
|
||||
@@ -5,6 +5,7 @@ set -e
|
||||
echo "--- Loading environment"
|
||||
source ./script/ci/includes.sh
|
||||
load_environment
|
||||
checkout_ofn_commit
|
||||
|
||||
echo "--- Verifying branch is based on current master"
|
||||
exit_unless_master_merged
|
||||
|
||||
Reference in New Issue
Block a user