Conditional setup_remote_docker command


#1

Hiya,

Im using the setup_remote_docker command to build my production containers, only this command only needs to be executed when im on a certain branch. So could you tell me how to make this call conditional?

- steps:
      - setup_remote_docker
      - run:
          name: Maybe deploy
          command: |
            if [ "${CIRCLE_BRANCH}" == "feature/circleci-2" ]; then
              bin/deploy staging
            fi
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              bin/deploy production
            fi

This will shave off an additional 1,5 minute for the branches that dont need to be pushed to production

Thanks!!!


#2

Currently, the only way to conditionally start the Docker engine is to trigger a new job with those if statements and deploy there.

https://circleci.com/docs/2.0/defining-multiple-jobs/


#3