Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Circleci: How to deploy depending on git tag

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.

like image 277
dsteinkopf Avatar asked Jun 13 '15 10:06

dsteinkopf


People also ask

How does CircleCI work with GitHub?

CircleCI automatically runs your build and test processes whenever you commit code, and then displays the build status in your GitHub branch.

How do I deploy in CircleCI?

Deployment job: To deploy your application, add a job to your . circleci/config. yml file and configure the job to run the steps you require. Visit the other pages in the deployment section of the documentation for example configurations for common deployment targets.

How do I add a repository to CircleCI?

Go to https://github.com/you/test-repo/settings/keys , and click Add Deploy Key. Enter a title in the "Title" field, then copy and paste the public key you created in step 1. Check Allow write access, then click Add key. Go to your project settings in the CircleCI app, select SSH Keys, and Add SSH key.


1 Answers

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
like image 176
Dean Avatar answered Oct 03 '22 20:10

Dean