Passing an array literal to contains() function causes syntax error

Not sure if this is a bug or if I am doing it wrong?

- name: Register/Restore Node Modules Cache - EPanel
  if: false == contains(['monarch', 'bloom'], github.event.repository.name)

Result:

### ERRORED 18:40:27Z

- Your workflow file was invalid: The pipeline is not valid. .github/workflows/main.yml (Line: 49, Col: 11): Unexpected symbol: '['. Located at position 19 within expression: false == contains(['monarch', 'bloom'],
3 Likes

Unfortunately the expression syntax doesn’t support JSON. An array would have to dereferenced from some object in the context - e.g. github.event.my_array

The current solution for the specific scenario is if github.event.repository.name == 'monarch' || github.event.repository.name == 'bloom'

4 Likes

There’s also the ability to do it as follows:
contains(fromJson('["monarch", "bloom"]'), github.event.repository.name)

4 Likes