Is there any way to write a filter for a single command rather than an entire job?

Is there any way to run single command like this:

run:
          name: Version Check
          command: echo "do something"

if branch !== ‘main’

I know you can do this

filters:
            branches:
              ignore: main

But I’m wondering if that filter can be applied to a single command rather than the entire workflow.

Hi @jmarx ,

The syntax will be different than when applying a filter for a job, but it is possible to set conditional steps using the when key.

Here are some pages in our documentation/knowledge base regarding conditional steps:

Configuring CircleCI - CircleCI
Conditional steps in jobs and conditional workflows – CircleCI Support Center

I believe for your use case, you can use a combination of not and equals, and pass in the branch name main.

Please have a look at the above pages, and let us know if you have any additional questions!