是否可以在 github 操作的 if 条件中进行模式匹配?

xen*_*ide 4 github github-actions

我目前正在这样做:

if: failure() && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/mybranch')
Run Code Online (Sandbox Code Playgroud)

但我们正在使用 git flow(令我非常懊恼)。

如何检查分支名称是否包含特定模式?

像这样的东西:

if: failure() && ( !(github.ref ~= 'feature/*' )
Run Code Online (Sandbox Code Playgroud)

xen*_*ide 5

contains看起来已经很不错了

        if: failure() && !contains( github.ref, 'feature' )
Run Code Online (Sandbox Code Playgroud)

  • 此链接可能是可用函数的更好参考 https://docs.github.com/en/actions/learn-github-actions/expressions#contains (2认同)