Skip to content

Commit

Permalink
chore(pipeline): deploy develop-v2
Browse files Browse the repository at this point in the history
- create a pipeline for deploying develop-v2

[ Fixes #164068943]
  • Loading branch information
WinstonKamau committed Feb 20, 2019
1 parent 3e42258 commit f85e38e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ workflows:
only:
- develop
- master
- develop-v2
- deploy:
requires:
- upgrade-database
Expand All @@ -92,4 +93,4 @@ workflows:
only:
- develop
- master
- design
- develop-v2
6 changes: 3 additions & 3 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ set_variables() {
GOOGLE_CLUSTER_NAME=${STAGING_CLUSTER_NAME}
DEPLOYMENT_NAME="${ENVIRONMENT}-${PROJECT_NAME}"
;;
design)
IMAGE_TAG="design-${COMMIT_HASH}"
develop-v2)
IMAGE_TAG="staging-v2-${COMMIT_HASH}"
ENVIRONMENT=staging
GOOGLE_COMPUTE_ZONE=${STAGING_ZONE}
GOOGLE_CLUSTER_NAME=${STAGING_CLUSTER_NAME}
DEPLOYMENT_NAME="design-${PROJECT_NAME}"
DEPLOYMENT_NAME="staging-v2-${PROJECT_NAME}"
;;
*)
echo "Err: This branch should not deploy."
Expand Down
15 changes: 15 additions & 0 deletions scripts/slack_notification.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ declare_env_variables() {
else
ENVIRONMENT="Staging"
fi
case "$CIRCLE_BRANCH" in
master)
ENVIRONMENT="Production"
;;
develop)
ENVIRONMENT="Staging"
;;
develop-v2)
ENVIRONMENT="Staging V2"
;;
*)
echo "Err: This branch should not deploy."
exit 1
;;
esac

if [ "$CIRCLE_JOB" == "upgrade-database" ]; then
upgrade_env_variables "$@"
Expand Down
45 changes: 31 additions & 14 deletions scripts/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,36 @@ set -o errexit
set -o pipefail

set_variables(){
if [ "$CIRCLE_BRANCH" == 'master' ]; then
APP_SETTINGS="Production"
CLOUDSQL_CONNECTION_NAME=${PRODUCTION_CLOUD_SQL_CONNECTION_NAME}
DATABASE_URL=${PRODUCTION_DATABASE_URL}
INSTANCE_NAME=${PRODUCTION_INSTANCE_NAME}
DATABASE_NAME=${PRODUCTION_DATABASE_NAME}
else
APP_SETTINGS="Staging"
CLOUDSQL_CONNECTION_NAME=${STAGING_CLOUD_SQL_CONNECTION_NAME}
DATABASE_URL=${STAGING_DATABASE_URL}
INSTANCE_NAME=${STAGING_INSTANCE_NAME}
DATABASE_NAME=${STAGING_DATABASE_NAME}
fi
case "$CIRCLE_BRANCH" in
master)
APP_SETTINGS="Production"
VERSION=""
CLOUDSQL_CONNECTION_NAME=${PRODUCTION_CLOUD_SQL_CONNECTION_NAME}
DATABASE_URL=${PRODUCTION_DATABASE_URL}
INSTANCE_NAME=${PRODUCTION_INSTANCE_NAME}
DATABASE_NAME=${PRODUCTION_DATABASE_NAME}
;;
develop)
APP_SETTINGS="Staging"
VERSION=""
CLOUDSQL_CONNECTION_NAME=${STAGING_CLOUD_SQL_CONNECTION_NAME}
DATABASE_URL=${STAGING_DATABASE_URL}
INSTANCE_NAME=${STAGING_INSTANCE_NAME}
DATABASE_NAME=${STAGING_DATABASE_NAME}
;;
develop-v2)
APP_SETTINGS="Staging"
VERSION="-v2"
CLOUDSQL_CONNECTION_NAME=${STAGING_CLOUD_SQL_CONNECTION_NAME}
DATABASE_URL=${STAGING_DATABASE_URL}
INSTANCE_NAME=${STAGING_INSTANCE_NAME}
DATABASE_NAME=${STAGING_V2_DATABASE_NAME}
;;
*)
echo "Err: This branch should not deploy."
exit 1
;;
esac
}

install_google_cloud_sdk(){
Expand All @@ -34,7 +51,7 @@ authenticate_google_cloud() {
}

export_data() {
DUMP_NAME=$(echo "${APP_SETTINGS}" | tr '[:upper:]' '[:lower:]')-sqldumpfile-$(date '+%Y-%m-%d-%H-%M-%S').gz
DUMP_NAME=$(echo "${APP_SETTINGS}" | tr '[:upper:]' '[:lower:]')${VERSION}-sqldumpfile-$(date '+%Y-%m-%d-%H-%M-%S').gz
gcloud sql export sql ${INSTANCE_NAME} gs://${SOCIETIES_GCP_BUCKET}/${DUMP_NAME} \
--database=${DATABASE_NAME}
}
Expand Down

0 comments on commit f85e38e

Please sign in to comment.