[英]Adding a binary to the PATH from a Docker GitHub Action for use by later workflow steps
I am trying to create a Dockerfile based action that adds a program to the $PATH
so that it can be used by later actions.我正在尝试创建一个基于 Dockerfile 的操作,该操作将程序添加到$PATH
以便以后的操作可以使用它。 My action runs code like this:我的操作运行如下代码:
mkdir -p $GITHUB_WORKSPACE/bin
echo "echo Hello, world!" > $GITHUB_WORKSPACE/bin/hello-world
echo "::add-path::$GITHUB_WORKSPACE/bin"
My test workflow uses this like so:我的测试工作流程是这样使用的:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1.0.0
- name: Add program to path
uses: ./
- name: Use program
run: hello-world
This fails because while the program has been added to $GITHUB_WORKSPACE/bin/hello-world
the value of $GITHUB_WORKSPACE
is different in the action and in the workspace step.这失败了,因为当程序已添加到$GITHUB_WORKSPACE/bin/hello-world
时, $GITHUB_WORKSPACE
的值在操作和工作区步骤中是不同的。
In the action it is /github/workspace/
, while in the workflow it is /home/runner/work/setup-gleam/setup-gleam/
, so the $PATH
addition set by the action is not correct.在动作中是/github/workspace/
,而在工作流中是/home/runner/work/setup-gleam/setup-gleam/
,所以动作设置的$PATH
添加不正确。
How can I add a file to a directory from a dockerfile based GitHub action so that it is on the path for the rest of the workflow?如何将文件从基于 dockerfile 的 GitHub 操作添加到目录,以便它位于工作流的 rest 的路径上? It seems that there is no writable $PATH
directory shared between dockerfile actions and non-dockerfile actions.似乎 dockerfile 操作和非 dockerfile 操作之间没有共享可写的$PATH
目录。
Runner path is stored in $RUNNER_WORKSPACE
environment variable and can be used to get the right path. Runner 路径存储在$RUNNER_WORKSPACE
环境变量中,可用于获取正确的路径。
echo "::add-path::$GITHUB_WORKSPACE/bin" # Make it accessible from docker containers
echo "::add-path::$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/bin" # Make it accessible from runner
But it looks more like a workaround than solution.但它看起来更像是一种解决方法而不是解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.