Circleci: How to deploy depending on git tag

dsteinkopf picture dsteinkopf · Jun 13, 2015 · Viewed 7.4k times · Source

Is there a way to restrict circleci deployment on checkings that have a specific git tag?

Currently I am using this

...
deployment:
  dockerhub:
    branch: master
    commands:
      - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
      - docker push abcdef

Instead of branch: master I would like to write something like tag: /release_.*/

Background: I would like to set docker tags depending on git tags. So for example, whenever something is committed to master, a new docker images with latest tag will be created and pushed. Whenever a special git tag is set (e.g. release_1.0_2015-06-13) a new docker image with a tag 1.0 will be created and pushed.

Alternative is to only use different branches according to the different tags. But I would like to use tags to mark a specific release.

Answer

Dean picture Dean · Aug 28, 2015

It looks like this was added since Kim answered.

Normally, pushing a tag will not run a build. If there is a deployment configuration with a tag property that matches the name of the tag you created, we will run the build and the deployment section that matches.

In the below example, pushing a tag named release-v1.05 would trigger a build & deployment. Pushing a tag qa-9502 would not trigger a build.

deployment:
  release:
    tag: /release-.*/
    owner: circleci
    commands:
      - ./deploy_master.sh