Closed DanyC97 closed 9 months ago
Hi @DanyC97
If you require validation for required arguments then it might be better to use workflow_dispatch
, which has some validation built into the GitHub API. See here.
As for why your workflow isn't working, are you saying that this condition doesn't work?
if: ${{ !contains(fromJson('["foo", "bar", "kilo", "alpha", "automation"]'), github.event.client_payload.slash_command.args.named.layer) }}
It looks ok, but it difficult to say. Is your debug step showing the correct value for github.event.client_payload.slash_command.args.named.layer
?
thank you @peter-evans for coming back to me.
After a bit more digging found the reason why it was not working, it was all to do with toJson
& fromJson
.
In case others bump into it, the expression is
check-slash-commands:
if: |
contains(toJson(github.event.client_payload.slash_command.args.named), 'layer') &&
!contains(toJson('["foo", "bar", "kilo", "alpha", "automation"]'), github.event.client_payload.slash_command.args.named.layer)
runs-on: ubuntu-latest
silly user error 🤦♂️
👋 @peter-evans , thanks a bunch for the very useful action.
I was wondering if you came across the following use case , if not will you be willing to accept an enhancement ?
Using your action i have defined a couple of commands where a named argument is always required (mandatory). To take it a step further i also want the named argument to accept and dispatch commands only if the value provided is part of a known list. Otherwise, it should not fire a dispatch event and return a message back to inform the OP.
I have tried something different however things are not working, not sure (yet) why
the workflow dispatcher
the repository_dispatch workflow
Since i didn't find any way to stop triggering any events nor , using advanced configuration, validate the named arg value it went the other side using a conditional expression.
Unfortunately the condition doesn't work as expected:
/hello layer=foo
is provided i do expect the entire job to be skipped/hello layer=xxxx
is provided i do expect the job to run and exit with posting a comment backNot sure if i'm doing anything wrong ...