Hello folks,
I’m trying to run some conditional steps using when to control when running or not a deployment step on my workflow as folllow.
version: 2.1
workflows:
ci-cd-production:
jobs:
- build
- deploy:
requires:
- build
jobs:
build:
docker:
- image: cimg/node:lts-browsers
steps:
- checkout
- run: echo "Run build Job"
deploy:
docker:
- image: cimg/node:lts-browsers
steps:
- run:
name: 'Checks if its a Pull Request (PR)'
command: |
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
isPullRequest=true
else
isPullRequest=false
fi
echo isPullRequest: $isPullRequest
echo export ISPULLREQUEST=$isPullRequest >> "$BASH_ENV"
- when:
condition:
equal: [ true, $isPullRequest ]
steps:
- run: echo "DEPLOY NOT EXECUTED"
- when:
condition:
equal: [ false, $isPullRequest ]
steps:
- run: echo "DEPLOYING APPLICATION..."
For some reason my when condition to identify if it’s a PR or not is not working.
Both conditions true and false are not executed when the workflow is loaded.
Anyone has any hint to help?
Thanks in advance,