allow overriding workdir for container jobs
See original GitHub issueDescribe the enhancement
Allow overriding container’s workdir.
Currently, even if passing --workdir=/somedir
to the container: options:
it does not override the first --workdir
option passed to docker create
by the runner.
It would be nice to be able to override the workdir
somehow, so that on self-hosted runners, after the job is done the checked out sources would not remain the in actions-runner/_work
directory. In container jobs it makes no sense to mount the external directory, as all the job steps are executed within the container anyway. If work dir is set to some in-container directory, then after the job is done the container is discarded and all the build artifacts are discarded as well, no separate cleanup is needed.
Code Snippet
container:
image: debian:buster
options: --workdir=/home/build/myrepo
This example currently will result in that --workdir
is passed twice to the docker create
. The first one is the default one which is --workdir /__w/myrepo/myrepo
and the second is the one indicated in options:
, but it looks like docker create
takes the first one and ignores the second one. So, there is no possibility to override the workdir
.
Need to exclude the default --workdir
option in case options:
contains custom --workdir
option.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:35
- Comments:13 (1 by maintainers)
Top GitHub Comments
I am having a similar issue. I need to place my code inside a specific directory in order to build it (which is the default workdir in my container). In my opinion, the runner should only set the workdir/HOME if they aren’t set (or provide a way to change the default values).
I am working around this limitation by providing a default workspace for the job. As follows:
Now any steps in the job will run as per new working directory. May be this is useful till the actual solution is implemented.
Note that, the marketplace actions might still work with the GITHUB_WORKSPACE location. So configure the action appropriately.