Mar*_*rco 7 github docker github-actions
我正在尝试在复合 GitHub Action 中传递一些动态创建的参数。
\n然而,文档缺少有关如何在这种情况下将参数传递给 docker 容器的示例。
\nhttps://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsstepsuses
\n在这里看看我想要实现的目标。
\nruns:\n using: \'composite\'\n steps:\n - name: compose arguments\n id: compose-args\n shell: bash\n run: |\n encoded_github="$(echo \'${{ inputs.github_context }}\' | base64)"\n encoded_runner="$(echo \'${{ inputs.runner_context }}\' | base64)"\n\n args=(\'${{ inputs.command }}\')\n args+=(\'${{ inputs.subcommand }}\')\n args+=(\'--github-context\')\n args+=("${encoded_github}")\n args+=(\'--runner-context\')\n args+=("${encoded_runner}")\n args+=(\'${{ inputs.arguments }}\')\n\n echo "::set-output name=provenance_args::$(echo "[$(printf "\\"%s\\"," ${args[*]})]" | sed \'s/,]$/]/\')"\n - name: Debug arguments\n shell: bash\n run: |\n echo Running slsa-provenance with following arguments\n echo ${{ steps.compose-args.outputs.provenance_args }}\n - uses: \'docker://ghcr.io/philips-labs/slsa-provenance:v0.5.0-draft\'\n with:\n args: ${{ fromJSON(steps.compose-args.outputs.provenance_args) }}\nRun Code Online (Sandbox Code Playgroud)\nfromJSON 从 bash 参数组成的数组中给我一个 JSON 对象。我假设这uses: \'docker://\xe2\x80\xa6部分应该以与基于 docker 的操作接收相同的方式接收它的参数。
例如:
\nruns:\n using: \'docker\'\n image: \'docker://ghcr.io/philips-labs/slsa-provenance:v0.4.0\'\n args:\n - "generate"\n - \'${{ inputs.subcommand }}\'\n - "-artifact_path"\n - \'${{ inputs.artifact_path }}\'\n - "-output_path"\n - \'${{ inputs.output_path }}\'\n - "-github_context"\n - \'${{ inputs.github_context }}\'\n - "-runner_context"\n - \'${{ inputs.runner_context }}\'\n - "-tag_name"\n - \'${{ inputs.tag_name }}\'\nRun Code Online (Sandbox Code Playgroud)\n不幸的是,我在 GitHub 操作工作流程中收到以下错误。
\nThe template is not valid. philips-labs/slsa-provenance-action/v0.5.0-draft/action.yaml (Line: 47, Col: 15): A sequence was not expected\nRun Code Online (Sandbox Code Playgroud)\n请参阅此处的工作流程。https://github.com/philips-labs/slsa-provenance-action/runs/4618706311?check_suite_focus=true
\nEuc*_*ues -2
我认为你可以通过 bash 命令运行:
- name: pull image
shell: bash
run: |
docker pull ghcr.io/philips-labs/slsa-provenance:v0.4.0
- name: run container
shell: bash
run: |
docker run --rm -i \
--workdir /github/workspace \
-v "/var/run/docker.sock":"/var/run/docker.sock" \
-v ${{ runner.temp }}/_github_home:"/github/home" \
-v ${{ github.workflow }}:"/github/workflow" \
-v ${{ runner.temp }}/_runner_file_commands:"/github/file_commands" \
-v ${{ github.workspace }}:"/github/workspace" \
ghcr.io/philips-labs/slsa-provenance:v0.4.0 \ # image
generate \ # start pass the args here, after the image
${{ 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 }}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2351 次 |
| 最近记录: |