Build required steps automatically for tag filtered workflows


#1

The default of tagged builds not running is fine in most cases, but it causes confusion when jobs which expect to run for tags are dependent on jobs which are not specified. I think unless a job specifically filters out certain tags, a downstream job that would be run should automatically run the upstream job. Deployment jobs will almost always be very specific in their filters and details, while the jobs they require are much more likely to be “benign” and able to run without negative impact.

The following workflow does not run when a new tag is pushed:

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - docker-latest:
          requires:
            - build
          filters:
            branches:
              only: master
      - docker-prod:
          requires:
            - build
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /^v[0-9]*(\.[0-9]*)*$/

The following workflow does run for a new tag:

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build:
          filters:
            tags:
              only: /.*/
      - docker-latest:
          requires:
            - build
          filters:
            branches:
              only: master
      - docker-prod:
          requires:
            - build
          filters:
            branches:
              ignore: /.*/
            tags:
              only: /^v[0-9]*(\.[0-9]*)*$/

#2