# 
defaults: &defaults
  working_directory: /build
  docker:
    - image: docker:17.06.0-ce-git

version: 2
jobs:
  build:
    <<: *defaults
    steps:
      - checkout
      - setup_remote_docker:
          docker_layer_caching: true
      - run:
          name: Install bash
          command: apk add --no-cache bash
      - run:
          name: Build image
          command: bin/build.sh
  deploy:
    <<: *defaults
    steps:
      - checkout
      - setup_remote_docker:
          docker_layer_caching: true
      - run:
          name: Install bash
          command: apk add --no-cache bash
      - run:
          name: Deploy image to Docker Hub
          command: |
            docker login --username ${DOCKER_USER} --password ${DOCKER_PASSWORD}
            bin/deploy.sh

workflows:
  version: 2
  build_deploy:
    jobs:
      - build:
          filters:
            tags:
              only:
                - /.*/
      - deploy:
          requires:
            - build
          filters:
            branches:
              only:
                - master
            tags:
              only:
                - /^v.*/

# 
defaults: &defaults
  working_directory: /build
  docker:
    - image: docker:17.06.0-ce-git

version: 2
jobs:
  build:
    <<: *defaults
    steps:
      - checkout
      - setup_remote_docker:
          docker_layer_caching: true
      - run:
          name: Install bash
          command: apk add --no-cache bash
      - run:
          name: Build image
          command: bin/build.sh
  deploy:
    <<: *defaults
    steps:
      - checkout
      - setup_remote_docker:
          docker_layer_caching: true
      - run:
          name: Install bash
          command: apk add --no-cache bash
      - run:
          name: Deploy image to Docker Hub
          command: |
            docker login --username ${DOCKER_USER} --password ${DOCKER_PASSWORD}
            bin/deploy.sh

workflows:
  version: 2
  nightly-workflow:
    triggers:
      - schedule:
          cron: "0 0 * * *"
          filters:
            branches:
              only:
                - master
    jobs:
      - build:
          environment:
            BUILD_DEV: "dev build"
          filters:
            tags:
              only:
                - /.*/
      - deploy:
          environment:
            BUILD_DEV: "dev build"
          requires:
            - build
          filters:
            branches:
              only:
                - master
            tags:
              only:
                - /^v.*/
  commit-workflow:
    jobs:
      - build:
          filters:
            tags:
              only:
                - /.*/
      - deploy:
          requires:
            - build
          filters:
            branches:
              only:
                - master
            tags:
              only:
                - /^v.*/

Use circleci to build nightly dev build
Use circleci to build nightly dev build
