version: 2
jobs:
  build-tag-publish:
    machine:
      image: ubuntu-1604:201903-01
    steps:
      - checkout
      - run:
          name: Build tested docker image and publish 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-tag-publish-deploy:
    jobs:
      - build-tag-publish:
          context: cyberdojo-context
          filters:
            branches:
              only: [ master ]
      - deploy-to-beta:
          context: cyberdojo-context
          requires: [ build-tag-publish ]
      - approve-to-prod:
          type: approval
          requires: [ deploy-to-beta ]
      - deploy-to-prod:
          context: cyberdojo-context
          requires: [ approve-to-prod ]

version: 2
jobs:
  build-tag-publish:
    machine:
      image: ubuntu-2004:202008-01
    steps:
      - checkout
      - run:
          name: Build tested docker image and publish 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-tag-publish-deploy:
    jobs:
      - build-tag-publish:
          context: cyberdojo-context
          filters:
            branches:
              only: [ master ]
      - deploy-to-beta:
          context: cyberdojo-context
          requires: [ build-tag-publish ]
      - approve-to-prod:
          type: approval
          requires: [ deploy-to-beta ]
      - deploy-to-prod:
          context: cyberdojo-context
          requires: [ approve-to-prod ]

Upgrade to newer CI machine image (Ubuntu 20.04)
Upgrade to newer CI machine image (Ubuntu 20.04)
