I’m trying to create a config file that follows the following pattern:
- Run a command (terraform) that will either return an exit code 0 (everything is fine) or 2 (changes are needed)
- If everything is fine (0 code) then the workflow is done and it can move on
- If the command says that things need changing (2 code), I want circleci to run a manual approval state so that I can check things over before it proceeds.
Is this possible?
I tried to do this with steps, but it appears that manual approval is only allowed for jobs. I found the very helpful step
condition: on_fail but I don’t know if or how it could trigger a different job to run or be skipped.
My first attempt went something like this:
- run: name: Plan Terraform command: | cd ./bin planresult=$(terraform plan) if [[ $? != 0 ]]; then exit 2 else exit 0 fi - when: condition: on_fail steps: ????