在GitHub操作变量中定义元素列表。

huangapple go评论58阅读模式
英文:

Define list of elements in a GitHub Action variable

问题

自从几周前 GitHub 引入了必需的工作流和配置变量后,现在我想定义一个全局的 GitHub Actions 工作流,其中使用的变量不是简单的文本字符串,而是一个元素列表。

TEST_OS_VERSION = ''"ubuntu", "ubuntu-20.04"''

os: [${{ vars.TEST_OS_VERSIONS }}]

似乎 GitHub 不喜欢这样 :-/

我已经尝试过 TEST_OS_VERSION = ''["ubuntu", "ubuntu-20.04"]''os: ${{vars.TEST_OS_VERSIONS }},但 GitHub 似乎也不喜欢它。

有没有关于如何存储一个包含元素的列表以在 GitHub 中使用的想法?

英文:

Since a few weeks GitHub introduced required workflows and configuration variables.

Now I want to define a global GitHub Actions workflow that uses a variable that is not a simple string of text, but a list of elements.

TEST_OS_VERSION = '"ubuntu", "ubuntu-20.04"'


        os: [${{ vars.TEST_OS_VERSIONS }}]

Seems that GitHub does not like that :-/

I already tried TEST_OS_VERSION = '["ubuntu", "ubuntu-20.04"]' and os: ${{vars.TEST_OS_VERSIONS }} but again GitHub does not like it either.

Any idea on how to store in a variable a list of elements to be used in GitHub?

答案1

得分: 1

"fromJSON" 是解决方案,如 @jonrsharpe 所提到的从此处获取

变量:["ubuntu", "ubuntu-20.04"]

yaml:os: ${{ fromJSON(vars.TEST_OS_VERSIONS) }}

英文:

As already mentions @jonrsharpe fromJSON is the solution:

Variable: ["ubuntu", "ubuntu-20.04"]

yaml: os: ${{ fromJSON(vars.TEST_OS_VERSIONS) }}

huangapple
  • 本文由 发表于 2023年2月9日 03:44:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75391000.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定