In my yaml file I can check if a variable starts with a string by doing the following:
- name: Testing negation of startsWith
if: startsWith(env.BRANCH_NAME, 'dog')
run: echo "This job is dog"
shell: cmd
I want to do something like this in Github in my yaml file to check if a variable doesn't start with a certain string except doing something like this will give a red line under cat saying tag suffix cannot contain flow indicator characters.
- name: Testing negation of startsWith
if: !(startsWith(env.BRANCH_NAME, 'cat'))
run: echo "This job is not a cat"
shell: cmd
I also tried doing the following but it says Unrecognized function: 'not'
- name: Testing negation of startsWith
if: not (startsWith(env.BRANCH_NAME, 'cat'))
run: echo "This job is not a cat"
shell: cmd
There should be an easy way to check if a variable doesn't start with a certain value given that checking for the positive case exists.
you can use the following syntax instead of wrapping the condition in quotes:
if: ${{ !startsWith(env.BRANCH_NAME, 'cat') }}
This will avoid linter errors