Conditionally run commands

I would like to conditionally exit a job. Basically, I’m curling some info from the PR, and, depending on the data from that request, writing to a file, or not. I would like to exit the job depending on whether the file exists or not.

I tried:

steps:
      - attach_workspace:
          at: ~/  deploy_info
      - run: if [ ! -f ~/deploy_info/test_tags.txt ] ; then exit 0 ; fi

But that just exits that command and continues with the job

There is no way to do this right now, outside of wrapping the entire job in this type of conditional statement.

I’m doing the reverse, i’m triggering a job based on the existing file using a curl against the API: https://circleci.com/docs/api/v1-reference/#new-build-branch