Workflow job: filter to only tags not working

Expected behavior: commits pushed to any branch without any tag do not run the job build-and-push-test

Actual behavior: all pushes without tags run the job.

What’d I miss? Yes I read other threads on this.

version: 2.1

orbs:
  node: circleci/node@4.1
  aws-ecr: circleci/aws-ecr@7.0.0

commands:
  dotenv:
    steps:
      - run:
          command: sh -c 'env' > .env
  showenv:
    steps:
      - run:
          command: |
            echo "PRE-STEPS - env:"
            cat .env

workflows:
  build_and_push:
    jobs:
      # TEST: build+push
      - aws-ecr/build-and-push-image:
          checkout: false
          repo: "${AWS_TEST_WEB_REPO}"
          tag: "circle-${CIRCLE_TAG}"

          name: build-and-push-test
          filters:
            tags:
              only: /^test.*/
          pre-steps:
            - checkout
            - dotenv
            - run:
                command: |
                  cat .env | sed \
                    # snip!
                    > .env
                  echo "NEXT_PUBLIC_IS_RUNNING_AS_TEST=true" >> .env
            - showenv

Fixed it. I was missing that you have to also ignore branches:

          filters:
            tags:
              only: /^test.*/
            branches:
              ignore: /.*/
1 Like

:wave: Hi @stclaironfire,

Indeed, as you already figured out, by default CircleCI will run builds for any branch but won’t build for tags unless they are explicitly specified in the config.yml filter(s).

For additional info, please see our documentation:

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