将步骤的输出设置为数组

Set output of step as array

我在 GitHub 操作中从我的存储库中获取 feature/* 分支列表,使用:

echo ::set-output name=branches::$( git branch -r | grep -i "feature/" | sed -e "s/.*origin\///" | tr "\n" " " )

但是,这个列表是字符串输出,我需要它在一个字符串数组中,所以我可以用它来调用另一个使用矩阵策略的工作流。

我尝试过多种策略,包括:

使用:

branches=($( git branch -r | grep -i "feature/" | sed -e "s/.*origin\///" | tr "\n" " " ))

:

echo ::set-output name=branches::${branches[@]} # also ${branches[*]}

给出了两个值的错误:“值的意外类型 'feature/quality-3 feature/test_feature',预期类型:序列。”

:

echo ::set-output name=branches::${branches} # or $branches

给出一个错误值 1:“值的意外类型 'feature/quality-3',预期类型:序列。”

您必须在作业之间传递 JSON 等数据:

使用以下组合:

Here 是 GitHUB

中的完整示例