From fe1e688a2e73c67386214c874b2de899e765d084 Mon Sep 17 00:00:00 2001 From: Alvin Huang Date: Thu, 25 Apr 2019 12:24:20 -0400 Subject: [PATCH] Add website analytics back (#5699) * add website analytics to build * add segment analytics env var check --- .circleci/config.yml | 15 +++++++++++++++ website/scripts/deploy.sh | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6ce34f5b5..dbb5c348f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -195,9 +195,24 @@ jobs: steps: - checkout: path: ~/project + # attach website build directory - attach_workspace: at: ~/project/website + + # restores gem cache + - restore_cache: + key: *RUBYGEM_CACHE_KEY + # rerun build with 'ENV=production' to add analytics + - run: + name: install gems + command: bundle check || bundle install --path vendor/bundle --retry=3 + + # rerun build with 'ENV=production' to add analytics + - run: + name: middleman build + command: bundle exec middleman build + - run: name: website deploy command: ./scripts/deploy.sh diff --git a/website/scripts/deploy.sh b/website/scripts/deploy.sh index 169641500..4c4c49c7a 100755 --- a/website/scripts/deploy.sh +++ b/website/scripts/deploy.sh @@ -30,6 +30,12 @@ if ! command -v "s3cmd" >/dev/null 2>&1; then exit 1 fi +# Ensure the proper analytics Segment ID is set +if [ "$ENV" != "production" ]; then + echo "ENV is not set to production for Segment Analytics!" + exit 1 +fi + # Get the parent directory of where this script is and cd there DIR="$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)"