How to Check if a string exist in another string with github action?

I have a github action, i have a list of words like this:

'["alpha", "beta", "preview", "experiment"]'
 

and i have a suffix string like this:

suffix = steps.get-version.outputs.version-suffix

now i want to check if any of words in list exist in suffix or not?
currently i am using this:

 - run: echo "IS_PRE_RELEASE=true" >> $env:GITHUB_ENV    
   if: contains(fromJson('["alpha", "beta", "preview", "experiment"]'), steps.get-version.outputs.version-suffix)


but there is an issue:

if

suffix = beta
output: IS_PRE_RELEASE updated to true

if

suffix = beta1
output: IS_PRE_RELEASE does not set

so issue is, only beta (alpha,…) accepted and other type of string does not accepted (beta1, beta.1,….)

i tried to change contains to startsWith but i get same result.
how i can fix this?

Leave a Comment