version: 2
jobs:
  build-publish:
    machine:
      image: ubuntu-1604:201903-01
    steps:
      - checkout
      - run:
          name: Build, test, tag, publish docker image on Dockerhub
          command: ./build_test_publish.sh

  deploy-to-beta:
    docker:
      - image: cyberdojo/gcloud-kubectl-helm
    steps:
      - checkout
      - run:
          name: Authenticate with gcloud, deploy to beta with helm
          command: ./.circleci/deploy_to_namespace.sh beta

  deploy-to-prod:
    docker:
      - image: cyberdojo/gcloud-kubectl-helm
    steps:
      - checkout
      - run:
          name: Authenticate with gcloud, deploy to prod with helm
          command: ./.circleci/deploy_to_namespace.sh prod

workflows:
  version: 2
  build-publish-deploy:
    jobs:
      - build-publish:
          context: cyberdojo-context
          filters:
            branches:
              only:
                  - master
      - deploy-to-beta:
          context: cyberdojo-context
          requires:
            - build-publish
      - approve-to-prod:
          type: approval
          requires:
            - deploy-to-beta
      - deploy-to-prod:
          context: cyberdojo-context
          requires:
            - approve-to-prod

version: 2
jobs:
  build-publish:
    machine:
      image: ubuntu-1604:201903-01
    steps:
      - checkout
      - run:
          name: Build, test, tag, publish docker image on Dockerhub
          command: |
            pwd
            ls -al
            ./build_test_publish.sh

  deploy-to-beta:
    docker:
      - image: cyberdojo/gcloud-kubectl-helm
    steps:
      - checkout
      - run:
          name: Authenticate with gcloud, deploy to beta with helm
          command: ./.circleci/deploy_to_namespace.sh beta

  deploy-to-prod:
    docker:
      - image: cyberdojo/gcloud-kubectl-helm
    steps:
      - checkout
      - run:
          name: Authenticate with gcloud, deploy to prod with helm
          command: ./.circleci/deploy_to_namespace.sh prod

workflows:
  version: 2
  build-publish-deploy:
    jobs:
      - build-publish:
          context: cyberdojo-context
          filters:
            branches:
              only:
                  - master
      - deploy-to-beta:
          context: cyberdojo-context
          requires:
            - build-publish
      - approve-to-prod:
          type: approval
          requires:
            - deploy-to-beta
      - deploy-to-prod:
          context: cyberdojo-context
          requires:
            - approve-to-prod

Add debug commands for CI run
Add debug commands for CI run
