Conditionally skip approval step in workflow

workflow

#1

I’d really like to be able to hold for approval only if a certain condition is met. Specifically, we’re running Terraform from CI, and a human is required to approve the planned infrastructure changes before they are applied. However, if there aren’t changes to be made, it’d be really nice to skip the approval step.


#2

Any updates on this one? I had a similar requirement, where I’d auto-deploy only if the branch is master. Tried adding a branch filter to the approval step which uses a regex to check if it’s the master branch. This however removes the deploy step altogether if the branch is master since the approval stage is not required in that case.

jobs:
  - build
  - hold:
      type: approval
      requires:
        - build
      filters:
        branches:
          only:
            - /^(?!.*^master$).*$/
  - deploy:
      requires:
        - hold

#3