我正在开发 GitHub Actionworkflow https://github.com/MathieuSoysal/Javadoc-publisher.yml/blob/4ea2062374784e3de840530c99365039f5fa76bb/action.yml#L47-L50使用数组作为输入。
我使用这个解决方案来模拟数组:
- uses: actions/my-custom-ci
with:
subdirectories: src/main/java src/test/java
但我想使用这样的解决方案:
- uses: actions/my-custom-ci
with:
subdirectories:
- src/main/java
- src/test/java
是否可以对自定义 GitHub Actions 使用数组输入?如果是,我们如何使用自定义 GitHub Actions 的数组输入?
在撰写此答案时,GitHub Actions 不支持array
类型作为操作的输入。它只支持string | number | boolean
(架构:with https://github.com/SchemaStore/schemastore/blob/e7de43504da53808eb2a11de4f5baa64933e7176/src/schemas/json/github-workflow.json#L788 ref: definitions/env https://github.com/SchemaStore/schemastore/blob/e7de43504da53808eb2a11de4f5baa64933e7176/src/schemas/json/github-workflow.json#L207)。所以你的方法目前是一个有效的解决方法。
请注意,GitHub 运行者有jq https://stedolan.github.io/jq/默认安装,GitHub Actions 提供了类似的方法fromJSON https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson, toJSON https://docs.github.com/en/actions/learn-github-actions/expressions#tojson and join https://docs.github.com/en/actions/learn-github-actions/expressions#join,如果您想要生成自定义操作的动态输入,这可以帮助您创建更清晰的解决方案。
你可以检查google-github-actions/get-secretmanager-secrets https://github.com/google-github-actions/get-secretmanager-secrets的实施,他们接受多个输入 https://github.com/google-github-actions/get-secretmanager-secrets#inputs由换行符指定,而不是作为yaml
array:
- id: 'secrets'
uses: 'google-github-actions/get-secretmanager-secrets@v1'
with:
secrets: |-
token:my-project/docker-registry-token
anotherOne:my-project/a-secret
anotherOneToo:my-project/another-secret
当然,这可能不是您想要实现的目标。并且可能不值得重构您的操作。但目前这是一个解决方法。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)