【发布时间】:2022-01-24 12:18:17
【问题描述】:
我正在尝试在复合 GitHub Action 中传递一些动态创建的参数。
然而,文档缺少关于在这种情况下如何将参数传递给 docker 容器的示例。
https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsstepsuses
在这里查看我想要实现的目标。
runs:
using: 'composite'
steps:
- name: compose arguments
id: compose-args
shell: bash
run: |
encoded_github="$(echo '${{ inputs.github_context }}' | base64)"
encoded_runner="$(echo '${{ inputs.runner_context }}' | base64)"
args=('${{ inputs.command }}')
args+=('${{ inputs.subcommand }}')
args+=('--github-context')
args+=("${encoded_github}")
args+=('--runner-context')
args+=("${encoded_runner}")
args+=('${{ inputs.arguments }}')
echo "::set-output name=provenance_args::$(echo "[$(printf "\"%s\"," ${args[*]})]" | sed 's/,]$/]/')"
- name: Debug arguments
shell: bash
run: |
echo Running slsa-provenance with following arguments
echo ${{ steps.compose-args.outputs.provenance_args }}
- uses: 'docker://ghcr.io/philips-labs/slsa-provenance:v0.5.0-draft'
with:
args: ${{ fromJSON(steps.compose-args.outputs.provenance_args) }}
fromJSON 从组合的 bash 参数数组中给了我一个 JSON 对象。我假设uses: 'docker://…part 应该以与基于 docker 的操作相同的方式接收它的参数。
例如:
runs:
using: 'docker'
image: 'docker://ghcr.io/philips-labs/slsa-provenance:v0.4.0'
args:
- "generate"
- '${{ inputs.subcommand }}'
- "-artifact_path"
- '${{ inputs.artifact_path }}'
- "-output_path"
- '${{ inputs.output_path }}'
- "-github_context"
- '${{ inputs.github_context }}'
- "-runner_context"
- '${{ inputs.runner_context }}'
- "-tag_name"
- '${{ inputs.tag_name }}'
很遗憾,我在 GitHub 操作工作流程中遇到以下错误。
The template is not valid. philips-labs/slsa-provenance-action/v0.5.0-draft/action.yaml (Line: 47, Col: 15): A sequence was not expected
在此处查看工作流程。 https://github.com/philips-labs/slsa-provenance-action/runs/4618706311?check_suite_focus=true
- 如何解决此错误?
- 目前的方法可以解决吗?
- 这是缺少的功能吗?
- 有什么替代方案?
【问题讨论】:
标签: docker github github-actions