为什么“静态”为什么Array不使用GitHub包含工作流的表达式吗?

发布于 2025-01-31 16:04:18 字数 440 浏览 1 评论 0原文

来自文档

contains('Hello world', 'llo')

不会:

contains(['6', '7', '8'], matrix.foo)

意外符号:'['。位于表达式中的位置10:包含(['6','7','8'],matrix.foo)

有任何方法可以检查该matrix.fo o是6 7或8使用包含

From the documentation, this works:

contains('Hello world', 'llo')

However, this will not:

contains(['6', '7', '8'], matrix.foo)

Unexpected symbol: '['. Located at position 10 within expression: contains(['6', '7', '8'], matrix.foo)

Is there any way to check the that matrix.foo is either 6, 7, or 8 using contains?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅哥哥的热头脑 2025-02-07 16:04:18

包含函数无法实现结果您还需要使用 fromjson 带有数组列表的功能。

在这种情况下,您的表达方式应该像这样:

if: contains(fromJson('["6", "7", "8"]'), matrix.foo)

相反:

if: ${{ !contains(fromJson('["6", "7", "8"]'), matrix.foo) }}

如果您想看一下,我在这里对其进行了测试:

The contains function can't achieve the result you expect alone, you would also need to use the fromJson function with an array list.

In that case, your expression should instead look like this:

if: contains(fromJson('["6", "7", "8"]'), matrix.foo)

and the opposite like this:

if: ${{ !contains(fromJson('["6", "7", "8"]'), matrix.foo) }}

I tested it here if you want to have a look:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文