From 44b3571e366c9a1b6e90dd629e6c6eaaf55bdbe0 Mon Sep 17 00:00:00 2001 From: Sushil Shinde Date: Fri, 22 May 2020 17:09:20 +0530 Subject: [PATCH 1/8] ci: deploying on qa env --- .circleci/config.yml | 35 ++++++++++++- deploy.sh | 119 ------------------------------------------- 2 files changed, 34 insertions(+), 120 deletions(-) delete mode 100755 deploy.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index c44c1dd181..9a8a81fdbc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,7 +91,33 @@ jobs: source awsenvconf source buildenvvar ./master_deploy.sh -d ECS -e DEV -t latest -s test_communityapp_taskvar -i communityapp - + # Build & Deploy against development backend + "build-qa": + <<: *defaults + steps: + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + # Build of Docker image. + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh DEV + ./buildenv.sh -e DEV -b qa_communityapp_buildvar,qa_communityapp_deployvar + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e DEV -t latest -s qa_communityapp_taskvar -i communityapp # Build & Deploy against prod api backend "build-prod-beta": <<: *defaults @@ -211,6 +237,13 @@ workflows: only: - develop - feature-contentful + # This is QA automation env + - "build-qa": + context: org-global + filters: + branches: + only: + - develop-on-qa-env # This is beta env for production soft releases - "build-prod-beta": context : org-global diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 4afa6d464a..0000000000 --- a/deploy.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail - -# more bash-friendly output for jq -JQ="jq --raw-output --exit-status" - -ENV=$1 -TAG=$2 -AWS_REGION=$(eval "echo \$${ENV}_AWS_REGION") -AWS_ECS_CLUSTER=$(eval "echo \$${ENV}_AWS_ECS_CLUSTER") -ACCOUNT_ID=$(eval "echo \$${ENV}_AWS_ACCOUNT_ID") - -AWS_ECS_SERVICE=$(eval "echo \$${ENV}_AWS_ECS_SERVICE") -AWS_REPOSITORY=$(eval "echo \$${ENV}_AWS_REPOSITORY") -AWS_ECS_TASK_FAMILY=$(eval "echo \$${ENV}_AWS_ECS_TASK_FAMILY") - -DD_SERVICE_NAME=$(eval "echo \$${ENV}_DD_SERVICE_NAME") -DD_TRACE_AGENT_HOSTNAME=$(eval "echo \$${ENV}_DD_TRACE_AGENT_HOSTNAME") - -echo $AWS_ECS_SERVICE -configure_aws_cli() { - AWS_ACCESS_KEY_ID=$(eval "echo \$${ENV}_AWS_ACCESS_KEY_ID") - AWS_SECRET_ACCESS_KEY=$(eval "echo \$${ENV}_AWS_SECRET_ACCESS_KEY") - aws --version - aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID - aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY - aws configure set default.region $AWS_REGION - aws configure set default.output json - echo "Configured AWS CLI." -} - -deploy_cluster() { - make_task_def - register_definition - if [[ $(aws ecs update-service --cluster $AWS_ECS_CLUSTER --service $AWS_ECS_SERVICE --task-definition $revision | $JQ '.service.taskDefinition') != $revision ]]; then - echo "Error updating service." - return 1 - fi - - echo "Deployed!" - return 0 -} - -make_task_def(){ - task_template='[ - { - "name": "%s", - "image": "%s.dkr.ecr.%s.amazonaws.com/%s:%s", - "essential": true, - "memory": 1000, - "cpu": 100, - "environment": [ - { - "name": "NODE_CONFIG_ENV", - "value": "%s" - }, - { - "name": "DD_SERVICE_NAME", - "value": "%s" - }, - { - "name": "DD_TRACE_AGENT_HOSTNAME", - "value": "%s" - } - ], - "portMappings": [ - { - "hostPort": 0, - "containerPort": 3000, - "protocol": "tcp" - } - ], - "logConfiguration": { - "logDriver": "awslogs", - "options": { - "awslogs-group": "/aws/ecs/%s", - "awslogs-region": "%s", - "awslogs-stream-prefix": "%s" - } - } - } - ]' - - if [ "$ENV" = "PROD" ]; then - NODE_CONFIG_ENV=production - elif [ "$ENV" = "PRODBETA" ]; then - NODE_CONFIG_ENV=production - elif [ "$ENV" = "PRODSTAGING" ]; then - NODE_CONFIG_ENV=production - elif [ "$ENV" = "DEV" ]; then - NODE_CONFIG_ENV=development - elif [ "$ENV" = "TEST" ]; then - NODE_CONFIG_ENV=development - fi - - task_def=$(printf "$task_template" $AWS_ECS_CLUSTER $ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $NODE_CONFIG_ENV $DD_SERVICE_NAME $DD_TRACE_AGENT_HOSTNAME $AWS_ECS_CLUSTER $AWS_REGION $AWS_ECS_CLUSTER) - echo $task_def -} - -push_ecr_image() { - echo "Pushing Docker Image..." - eval $(aws ecr get-login --region $AWS_REGION --no-include-email) - docker push $ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$AWS_REPOSITORY:$TAG - echo "Docker Image published." -} - -register_definition() { - if revision=$(aws ecs register-task-definition --container-definitions "$task_def" --family $AWS_ECS_TASK_FAMILY | $JQ '.taskDefinition.taskDefinitionArn'); then - echo "Revision: $revision" - else - echo "Failed to register task definition" - return 1 - fi -} - -configure_aws_cli -push_ecr_image -deploy_cluster - From 6cc126043566cc54327f1ccce714097bfd1dd10b Mon Sep 17 00:00:00 2001 From: Sushil Shinde Date: Fri, 22 May 2020 17:16:39 +0530 Subject: [PATCH 2/8] ci: fixed config file --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9a8a81fdbc..b4a25742b3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -117,7 +117,7 @@ jobs: command: | source awsenvconf source buildenvvar - ./master_deploy.sh -d ECS -e DEV -t latest -s qa_communityapp_taskvar -i communityapp + ./master_deploy.sh -d ECS -e DEV -t latest -s qa_communityapp_taskvar -i communityapp # Build & Deploy against prod api backend "build-prod-beta": <<: *defaults From 11c2c27db3b5ffbe526ca5be8e230630a1f4865c Mon Sep 17 00:00:00 2001 From: Sushil Shinde Date: Fri, 22 May 2020 17:19:12 +0530 Subject: [PATCH 3/8] ci: fixed config file --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b4a25742b3..6cb7214234 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -243,7 +243,7 @@ workflows: filters: branches: only: - - develop-on-qa-env + - develop-on-qa-env # This is beta env for production soft releases - "build-prod-beta": context : org-global From 19d92653c98e0f59ba418e758ec7eaa55caf3e10 Mon Sep 17 00:00:00 2001 From: Sushil Shinde Date: Fri, 22 May 2020 17:20:31 +0530 Subject: [PATCH 4/8] ci: fixed file format --- .circleci/config.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6cb7214234..69c860387a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -237,13 +237,6 @@ workflows: only: - develop - feature-contentful - # This is QA automation env - - "build-qa": - context: org-global - filters: - branches: - only: - - develop-on-qa-env # This is beta env for production soft releases - "build-prod-beta": context : org-global From 4ec7b03399fd29dcdf6e1c9907dabf7bc995a74b Mon Sep 17 00:00:00 2001 From: Sushil Shinde Date: Fri, 22 May 2020 17:23:46 +0530 Subject: [PATCH 5/8] ci: fixing file --- .circleci/config.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 69c860387a..6cf568d4dd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -237,6 +237,13 @@ workflows: only: - develop - feature-contentful + # This is alternate dev env for parallel testing + - "build-qa": + context : org-global + filters: + branches: + only: + - develop-on-qa-env # This is beta env for production soft releases - "build-prod-beta": context : org-global From 1a8aacb2185b47f0532727a22bb4aee59ec27832 Mon Sep 17 00:00:00 2001 From: Sushil Shinde Date: Fri, 22 May 2020 17:29:00 +0530 Subject: [PATCH 6/8] ci: fixing file --- .circleci/config.yml | 58 +++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6cf568d4dd..82ba682730 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,33 +91,35 @@ jobs: source awsenvconf source buildenvvar ./master_deploy.sh -d ECS -e DEV -t latest -s test_communityapp_taskvar -i communityapp - # Build & Deploy against development backend - "build-qa": - <<: *defaults - steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - # Build of Docker image. - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh DEV - ./buildenv.sh -e DEV -b qa_communityapp_buildvar,qa_communityapp_deployvar - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e DEV -t latest -s qa_communityapp_taskvar -i communityapp + + # Build & Deploy against testing backend + "build-qa": + <<: *defaults + steps: + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh DEV + ./buildenv.sh -e DEV -b qa_communityapp_buildvar,qa_communityapp_deployvar + # Build of Docker image. + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e DEV -t latest -s qa_communityapp_taskvar -i communityapp + # Build & Deploy against prod api backend "build-prod-beta": <<: *defaults @@ -243,7 +245,7 @@ workflows: filters: branches: only: - - develop-on-qa-env + - develop-on-qa-env # This is beta env for production soft releases - "build-prod-beta": context : org-global From 9c40ac57c77c3b851359775727a7c4873096fe66 Mon Sep 17 00:00:00 2001 From: Sushil Shinde Date: Fri, 22 May 2020 17:31:46 +0530 Subject: [PATCH 7/8] ci: fixed config file --- .circleci/config.yml | 54 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 82ba682730..cc5753f9f0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -92,33 +92,33 @@ jobs: source buildenvvar ./master_deploy.sh -d ECS -e DEV -t latest -s test_communityapp_taskvar -i communityapp - # Build & Deploy against testing backend - "build-qa": - <<: *defaults - steps: - # Initialization. - - checkout - - setup_remote_docker - - run: *install_dependency - - run: *install_deploysuite - # Restoration of node_modules from cache. - - restore_cache: *restore_cache_settings_for_build - - run: - name: "configuring environment" - command: | - ./awsconfiguration.sh DEV - ./buildenv.sh -e DEV -b qa_communityapp_buildvar,qa_communityapp_deployvar - # Build of Docker image. - - run: *build_docker_image - # Caching node modules. - - save_cache: *save_cache_settings - # Deployment. - - deploy: - name: Running MasterScript - command: | - source awsenvconf - source buildenvvar - ./master_deploy.sh -d ECS -e DEV -t latest -s qa_communityapp_taskvar -i communityapp + # Build & Deploy against testing backend + "build-qa": + <<: *defaults + steps: + # Initialization. + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + # Restoration of node_modules from cache. + - restore_cache: *restore_cache_settings_for_build + - run: + name: "configuring environment" + command: | + ./awsconfiguration.sh DEV + ./buildenv.sh -e DEV -b qa_communityapp_buildvar,qa_communityapp_deployvar + # Build of Docker image. + - run: *build_docker_image + # Caching node modules. + - save_cache: *save_cache_settings + # Deployment. + - deploy: + name: Running MasterScript + command: | + source awsenvconf + source buildenvvar + ./master_deploy.sh -d ECS -e DEV -t latest -s qa_communityapp_taskvar -i communityapp # Build & Deploy against prod api backend "build-prod-beta": From 6999d78fb206be160b641132a70a8af05fb74aea Mon Sep 17 00:00:00 2001 From: Sushil Shinde Date: Fri, 22 May 2020 17:34:21 +0530 Subject: [PATCH 8/8] ci: fixed file scheme --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cc5753f9f0..2540011007 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -241,10 +241,10 @@ workflows: - feature-contentful # This is alternate dev env for parallel testing - "build-qa": - context : org-global - filters: - branches: - only: + context : org-global + filters: + branches: + only: - develop-on-qa-env # This is beta env for production soft releases - "build-prod-beta":