labs42io / circleci-monorepo

An example of monorepo with CircleCI using conditional workflows and pipeline parameters.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve documentation on dependencies with Advanced Logic in Config

BigsonLvrocha opened this issue · comments

Advanced logic in Config is a thing now in circleci, so, it should be documented, it wwould be a solution without change the script

the announcement is here

So, given 2 packages, api and service that depends on common, the script should be ok with

workflows:
  version: 2

  # The main workflow responsible for triggering all other workflows
  # in which changes are detected.
  ci:
    when: << pipeline.parameters.trigger >>
    jobs:
      - trigger-workflows


  # Workflows defined for each package.

  api:
    when: 
      or: 
        - << pipeline.parameters.api >>
        - << pipeline.parameters.common >>
    jobs:
      - build:
          name: api-build
          package_name: api
      - deploy:
          name: api-deploy
          package_name: api
          requires:
            - api-build

service:
    when: 
      or: 
        - << pipeline.parameters.service >>
        - << pipeline.parameters.common >>
    jobs:
      - build:
          name: service-build
          package_name: service
      - deploy:
          name: service-deploy
          package_name: service
          requires:
            - service-build

Thanks for this nice example @BigsonLvrocha. A PR is more than welcome as I don't have too much time for this right now.

Yeah, I'm doing it right now