version: 2.1 jobs: build: docker: - image: 'ubuntu:latest' steps: - checkout - run: echo "this is the build job" test: docker: - image: 'ubuntu:latest' steps: - checkout - run: echo "this is the test job" deploy: docker: - image: 'ubuntu:latest' steps: - run: echo "Deploy to prodlive" workflows: build: # This workflow will run on all branches except 'main' and will not run on tags jobs: - test: filters: branches: ignore: main staging: # This workflow will only run on 'main' and will not run on tags jobs: - test: filters: &filters-staging # this yaml anchor is setting these values to "filters-staging" branches: only: main tags: ignore: /.*/ - deploy: requires: - test filters: <<: *filters-staging # this is calling the previously set yaml anchor production: # This workflow will only run on tags (specifically starting with 'v.') and will not run on branches jobs: - test: filters: &filters-production # this yaml anchor is setting these values to "filters-production" branches: ignore: /.*/ tags: only: /^v.*/ - deploy: requires: - test filters: <<: *filters-production # this is calling the previously set yaml anchor