Branches filter doesn't work, job always run?

circle.yml
workflow
2.0
#1

We have the following config .yaml file, which includes a filter for master branch only.
However, this seems to also run on every pull request, even one made to develop and doesn’t include master at all.

File:
version: 2.1
jobs:
  test:
    docker:
    - image: cirrusci/flutter
    steps:
      - checkout
      - run: ./ci/test.sh
      - run: flutter doctor
      - run: flutter test
  publish:
    docker:
      - image: cirrusci/flutter
    working_directory: ~/msh
    environment:
      GRADLE_OPTS: -Dorg.gradle.daemon=false
    steps:
      - checkout:
          post:
            cp android/local.properties.ci android/local.properties
      - run:
          name: Install fastlane
          command: cd android && bundle install
      - run:
          name: Store the google play key
          command: echo $ANDROID_SVC_ACC > ~/secret.json
      - run:
          name: Init fastlane supply
          command: cd android && bundle exec fastlane supply init
      - run:
          name: create key file
          command: ./ci/create_jks.sh
      - run:
          name: Create bundle
          command: flutter build appbundle --release
      - run:
          name: Publish to store
          command: cd android && bundle exec fastlane android deploy

workflows:
  version: 2

  test_and_publish:
    jobs:
      - test
      - publish:
        filters:
          branches:
            only:
            - master
1 Like
#2

Same issue here. We’d like to build only master, but gh-pages branch if built after master succeed.
CircleCI gh-pages

Following the configuration file:

version: 2
jobs:
  build:
    docker:
      - image: circleci/node:lts
    branches:
      only:
        - master
    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-

      - run: yarn install

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run: yarn lint
      - run: yarn test
      - run: yarn clean
      - run: yarn build
      - run: git config --global user.email $GH_EMAIL
      - run: git config --global user.name "$GH_NAME"
      - run: yarn deploy-gh
#3

@matanshukry: I wonder if it would be worth trying the regex form of the filter?

@carlosvin: your filter is on the job, and not in a workflow. I seem to recall there are some filtering problems with that. Try moving the filter to a workflow, and then maybe try what I’ve suggested above.

1 Like