version: 2
jobs:
  build:
    machine: true
    environment:
      CLOUDSDK_CORE_DISABLE_PROMPTS: 1
      PRIVATE_REGISTRY: us.gcr.io/code_climate

    steps:
      # CircleCI 2.0 doesn't expand env vars yet so we have to do it manually.
      - run:
          name: Env
          command: |
            echo 'export IMAGE_NAME="${PRIVATE_REGISTRY}/${CIRCLE_PROJECT_REPONAME}:b${CIRCLE_BUILD_NUM}"' >> ${BASH_ENV}
      - checkout
      - run:
          name: Build image
          command: make image
      - run:
          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 --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:
      docker_layer_caching: false
    working_directory: ~/codeclimate/codeclimate-gotvet
    steps:
      - checkout
      - run: make image

  release_images:
    machine:
      docker_layer_caching: false
    working_directory: ~/codeclimate/codeclimate-gotvet
    steps:
      - checkout
      - run:
          name: Validate owner
          command: |
            if [ "$CIRCLE_PROJECT_USERNAME" -ne "codeclimate" ]
            then
              echo "Skipping release for non-codeclimate branches"
              circleci step halt
            fi
      - run: make image
      - run: echo "$GCR_JSON_KEY" | docker login -u _json_key --password-stdin us.gcr.io
      - run:
          name: Push image to GCR
          command: |
            docker tag codeclimate/codeclimate-gotvet \
              us.gcr.io/code-climate/codeclimate-gotvet:b$CIRCLE_BUILD_NUM
            docker push us.gcr.io/code-climate/codeclimate-gotvet:b$CIRCLE_BUILD_NUM

workflows:
  version: 2
  build_deploy:
    jobs:
      - build
      - release_images:
          requires:
            - build
          filters:
            branches:
              only: /master|channel\/[\w-]+/
notify:
  webhooks:
    - url: https://cc-slack-proxy.herokuapp.com/circle

Add correct steps for shipbot to pick it up
Add correct steps for shipbot to pick it up
