How to use pre post scripts in a custom Action

Hi

I’m trying to use the pre/post scripts as documented here: Metadata syntax for GitHub Actions - GitHub Docs

If pre and post are working properly, I’m failing to use pre-if/post-if with anything else than success() failure().

If I copy paste the documentation code

  pre: 'cleanup.js'
  pre-if: 'runner.os == linux'

I get an error “The template is not valid. GitHub.DistributedTask.Expressions2.ParseException: Unrecognized named-value: ‘linux’. Located at position 14 within expression: runner.os == linux at GitHub.DistributedTask.Expressions2”

Either I’m dumb or the documentation is incorrect.
it looks like it takes “linux” as a variable instead of a value, and if I try to add quotes around it to use it as a string, then I get another error “Unexpected symbol: ‘“ubuntu-latest”’”

I found nowhere on internet not in published actions someone using this feature (pre-if or post-if). Can someone give a try and tell me that I’m not totally stupid please :slight_smile:

ok, found it. I put the answer in case someone has the same issue. the documentation IS INCORRECT.

The right format does not have the first quote

doc says:

pre-if: 'runner.os == linux'

while it works with

pre-if: runner.os == 'linux'