Define Workflow in Orb

It seems as if it is possible to define a workflow within an orb, I have done this and have validated the orb successfully with workflows within, but how do I use those in a config file that imports the orb?

I have tried this, but it just tells me I need a required [jobs] key so it thinks I’m trying to define a new workflow.

version: 2.1

orbs:
  tf: <orb>

workflows:
  tf/scheduled-rollout: {}
  tf/scheduled-teardown: {}

I don’t need to include any parameters or anything, just need to tell CircleCI to include those workflows into this project. Is this possible?

Hi there @celestialorb

Thanks for pushing the envelope here!

I don’t believe this is possible yet, but it’s on our list of new features we want to ship, so it should be coming at some point.

I’m curious, though—since you got your orb to validate, can you share your orb source? I’d love to see how you got as far as you did.

Hello @rose !

Sure thing, what’s the preferred way to share source, are you able to pull source from just the orb name? The dev version currently has the workflows defined within it, its identifier is: ccpgames/devops-tf@dev:latest. The source is a bit lengthy at present so to avoid clutter I’ll just put the workflows section here:

Note: rollout and destroy are jobs defined elsewhere in the orb.

workflows:
  scheduled-rollout:
    jobs:
    - rollout
    triggers:
    - schedule:
        cron: "0 7 * * MON-FRI"
        filters:
          branches:
            only:
            - release-staging

  scheduled-teardown:
    jobs:
    - destroy
    triggers:
    - schedule:
        cron: "0 19 * * MON-FRI"
        filters:
          branches:
            only:
            - release-staging
1 Like

Mmm, interesting, I see!

There’s no top-level understanding of a workflows key within Orbs, currently, so that’s the barrier here. I think your best bet is defining your jobs in the orb, and using the examples key to lay out how you’re imagining those jobs being combined together.

Thanks!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.