Tagged workflow runs twice

Hi, I’m using the following configuration:

version: 2
jobs:
  build:
    working_directory: /ci-java-node
    docker:
      - image: docker:17.05.0-ce-git

    steps:
      - checkout
      - setup_remote_docker

      - run:
          name: Build docker images
          command: |
            docker build -t ci-java-node .
            docker tag ci-java-node $DOCKER_HUB_USER_ID/ci-java-node:$CIRCLE_TAG
            docker tag ci-java-node $DOCKER_HUB_USER_ID/ci-java-node:latest
      - deploy:
          name: Publish application to docker hub
          command: |
            docker login -e $DOCKER_HUB_EMAIL -u $DOCKER_HUB_USER_ID -p $DOCKER_HUB_PWD
            docker push $DOCKER_HUB_USER_ID/ci-java-node:$CIRCLE_TAG
            docker push $DOCKER_HUB_USER_ID/ci-java-node:latest
workflows:
  version: 2
  build_and_deploy:
    jobs:
      - build:
          filters:
            tags:
              only: /.*/

but when I do the following:

$ git commit -am "chore: version 0.1.2"
$ git tag -a 0.1.2 -m "0.1.2"
$ git push origin master --tags

The build job runs twice, one time for the commit and the other time for the tag.

I’ve also verified that my GitHub repository has only one WebHook installed.
How can I run my workflow only for the tag?
Thanks

It’s running once for each push type because that’s how it’s configed. All branches on run on CircleCI by default so you’d need to add a filter to ignore all branch names if you only want it to run on a tag push.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.