version: 2
jobs:
  test:
    docker:
      - image: artsy/hokusai
    working_directory: ~/doppler
    steps:
      - add_ssh_keys
      - checkout
      - setup_remote_docker
      - run:
          name: Test
          command: hokusai test
          no_output_timeout: 1h
  push:
    docker:
      - image: artsy/hokusai
    steps:
      - add_ssh_keys
      - checkout
      - setup_remote_docker
      - run:
          name: Push
          command: hokusai registry push --tag $CIRCLE_SHA1 --force --overwrite
  deploy:
    docker:
      - image: artsy/hokusai
    steps:
      - add_ssh_keys
      - checkout
      - run:
          name: Configure
          command: hokusai configure --kubectl-version 1.10.7 --s3-bucket artsy-citadel --s3-key k8s/config --platform linux
      - run:
          name: Deploy
          command: hokusai staging deploy $CIRCLE_SHA1
workflows:
  version: 2
  default:
    jobs:
      - test
      - push:
          filters:
            branches:
              only: master
          requires:
            - test
      - deploy:
          filters:
            branches:
              only: master
          requires:
            - push

version: 2
jobs:
  test:
    docker:
      - image: artsy/hokusai
    working_directory: ~/doppler
    steps:
      - add_ssh_keys
      - checkout
      - setup_remote_docker
      - run:
          name: Test
          command: hokusai test
          no_output_timeout: 1h
  push:
    docker:
      - image: artsy/hokusai
    steps:
      - add_ssh_keys
      - checkout
      - setup_remote_docker
      - run:
          name: Push
          command: hokusai registry push --tag $CIRCLE_SHA1 --force --overwrite
  staging_deploy:
    docker:
      - image: artsy/hokusai
    steps:
      - add_ssh_keys
      - checkout
      - run:
          name: Configure
          command: hokusai configure --kubectl-version 1.10.7 --s3-bucket artsy-citadel --s3-key k8s/config --platform linux
      - run:
          name: Deploy
          command: hokusai staging deploy $CIRCLE_SHA1
  production_deploy:
    docker:
      - image: artsy/hokusai
    steps:
      - add_ssh_keys
      - checkout
      - setup_remote_docker
      - run:
          name: Configure
          command: hokusai configure --kubectl-version 1.6.3 --s3-bucket artsy-citadel --s3-key k8s/config --platform linux
      - run:
          name: Promote
          command: hokusai pipeline promote
          no_output_timeout: 30m
workflows:
  version: 2
  default:
    jobs:
      - test:
          filters:
            branches:
              ignore: release
      - push:
          filters:
            branches:
              only: master
          requires:
            - test
      - staging_deploy:
          filters:
            branches:
              only: master
          requires:
            - push
      - production_deploy:
          filters:
            branches:
              only:
                - release

Deploy to production when merging into the release branch.
Deploy to production when merging into the release branch.
