Dynamically choosing s3 bucket to sync to based on branch name


Right now I have a circle.yml file that has specific branch names under deployment and commands to run based on the branch name. Right now the commands just build our app and deploy it to specific s3 buckets.

I would like to specify a set of deployment commands for every branch name, where the command syncing with an s3 bucket is able to base the bucket name on the branch name.

What is the best way to achieve this?


Can you share the commands being used?

The $CIRCLE_BRANCH environment variable should be able to help.

ref: https://circleci.com/docs/environment-variables#build-details


That’s right—you can either use the $CIRCLE_BRANCH variable inside the command or write an if clause based on the value of that:

    branch: /.*/
      - if [[ $CIRCLE_BRANCH == "master" ]]; then do-production-deployment; fi


Apologies for the late reply and thank you both. @alexey seems to have solved my problem with branch : /.*/. From there I can implement any logic in bash