我正试图传递一些动态创建的参数到一个组合GitHub Action中。
然而,文档缺乏如何将参数传递给docker容器的示例。
请参阅此处我要实现的内容:https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsstepsuses。
然而,文档缺乏如何将参数传递给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://…
部分应该像基于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 Actions工作流程中,我遇到了以下错误。
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
- 我该如何解决这个错误?
- 当前的方法可以解决吗?
- 这是一个缺失的功能吗?
- 是否有其他替代方案?
uses: docker://...
会发生什么。 - Alexis