Skip to content

The dynamic-base orb - determine the base branch dynamically and continue a pipeline with conditional parameters

Notifications You must be signed in to change notification settings

circle-makotom-orbs/dynamic-base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dynamic-base

Example usage

Prerequisite: Configure GITHUB_API_TOKEN project environment variable with a GitHub PAT that can access PRs of interest first.

version: 2.1

orbs:
  dynamic-base: circle-makotom-orbs/dynamic-base@volatile

parameters:
  is-continuation:
    type: boolean
    default: false
  run-x:
    type: boolean
    default: false
  run-y:
    type: boolean
    default: false
  run-all:
    type: boolean
    default: false

setup: << ! pipeline.parameters.is-continuation >>

jobs:
  build:
    docker:
      - image: alpine
    steps:
      - run: echo Build

  test:
    docker:
      - image: alpine
    steps:
      - when:
          condition:
            or:
              - << pipeline.parameters.run-x >>
              - << pipeline.parameters.run-all >>
          steps:
            - run: echo Test X
      - when:
          condition:
            or:
              - << pipeline.parameters.run-y >>
              - << pipeline.parameters.run-all >>
          steps:
            - run: echo Test Y

  deploy:
    docker:
      - image: alpine
    steps:
      - run: echo Deploy

workflows:
  # This is where dynamic determination of the base branch and parameter values happens
  setup:
    when:
      not: << pipeline.parameters.is-continuation >>
    jobs:
      - dynamic-base/determine-base-and-continue-with-params:
          continue-config-path: .circleci/config.yml

          # For parameter condition statements, each row should follow this format:
          # grep-pattern "\t" name-of-param-to-assert
          # .* -> is-continuation is a convenient gimmick to reuse the same config for both setup and continuation, by dynamically flipping the `setup` key
          parameter-conditions: |
            .*	is-continuation
            dir-a/.*	run-x
            dir-b/.*	run-y
            .circleci/config.yml	run-all

          default-branch: main
          force-all: false

  build-test-deploy:
    when: << pipeline.parameters.is-continuation >>
    jobs:
      - build
      - test:
          requires:
            - build
      - deploy:
          requires:
            - test

About

The dynamic-base orb - determine the base branch dynamically and continue a pipeline with conditional parameters

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages