version: 2
jobs:
  build:
    machine:
      enabled: true
      image: circleci/classic:201710-02
    environment:
      CLOUDSDK_CORE_DISABLE_PROMPTS: 1
      PRIVATE_REGISTRY: us.gcr.io/code_climate
      IMAGE_NAME: "${PRIVATE_REGISTRY}/${CIRCLE_PROJECT_REPONAME}-b${CIRCLE_BUILD_NUM}"
    steps:
      - checkout
      - run:
          name: Prebuild images
          command: make test-image
      - run:
          name: Tests
          command: make test
      - deploy:
          name: Deployment
          command: |
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              echo ${GCLOUD_JSON_KEY_BASE64} | sed 's/ //g' | base64 -d > /tmp/gcloud_key.json
              curl https://sdk.cloud.google.com | bash
              gcloud auth activate-service-account ${gcloud_account_email} --key-file /tmp/gcloud_key.json
              gcloud docker -a
              docker push "${IMAGE_NAME}"
            fi

notify:
  webhooks:
    - url: https://cc-slack-proxy.herokuapp.com/circle

version: 2
jobs:
  build:
    machine:
      enabled: true
      image: circleci/classic:201709-01
    environment:
      CLOUDSDK_CORE_DISABLE_PROMPTS: 1
      PRIVATE_REGISTRY: us.gcr.io/code_climate
      IMAGE_NAME: ${PRIVATE_REGISTRY}/${CIRCLE_PROJECT_REPONAME}:b${CIRCLE_BUILD_NUM}
    steps:
      - checkout
      - run:
          name: Prebuild images
          command: make test-image
      - run:
          name: Tests
          command: make test
      - deploy:
          name: Deployment
          command: |
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              echo ${GCLOUD_JSON_KEY_BASE64} | sed 's/ //g' | base64 -d > /tmp/gcloud_key.json
              curl https://sdk.cloud.google.com | bash
              gcloud auth activate-service-account ${gcloud_account_email} --key-file /tmp/gcloud_key.json
              gcloud docker -a
              docker push ${IMAGE_NAME}
            fi

notify:
  webhooks:
    - url: https://cc-slack-proxy.herokuapp.com/circle

Revert "Attempt to make CircleCI builds run again."
Revert "Attempt to make CircleCI builds run again."

This reverts commit 0ad60b6447dbb11806544b01fe78691d2aae2f11.
