diff options
author | Zettat123 <zettat123@gmail.com> | 2023-04-28 16:03:52 +0200 |
---|---|---|
committer | Jason Song <i@wolfogre.com> | 2023-04-28 16:03:52 +0200 |
commit | 35400f76fa20a31f56bf9836f7720d1ff4713ea4 (patch) | |
tree | 79fce85db16fee82d0992ad4d0b55acee032099b /internal/app/run/runner.go | |
parent | Update docker image tag (#153) (diff) | |
download | forgejo-runner-35400f76fa20a31f56bf9836f7720d1ff4713ea4.tar.xz forgejo-runner-35400f76fa20a31f56bf9836f7720d1ff4713ea4.zip |
Add parent directory for working directory (#154)
Fixes #145
At present, the working directory of a work flow is a path like `/<owner>/<repo>`, so the directory may conflict with system directory like `/usr/bin`. We need to add a parent directory for the working directory.
In this PR, the parent directory is `/workspace` by default and users could configure it by the `workdir_parent` option.
This change doesn't affect the host mode because in host mode the working directory will always be in `$HOME/.cache/act/` directory.
Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/154
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>
Diffstat (limited to 'internal/app/run/runner.go')
-rw-r--r-- | internal/app/run/runner.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go index 6a98de7..c5801eb 100644 --- a/internal/app/run/runner.go +++ b/internal/app/run/runner.go @@ -166,9 +166,9 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. } runnerConfig := &runner.Config{ - // On Linux, Workdir will be like "/<owner>/<repo>" - // On Windows, Workdir will be like "\<owner>\<repo>" - Workdir: filepath.FromSlash(string(filepath.Separator) + preset.Repository), + // On Linux, Workdir will be like "/<parent_directory>/<owner>/<repo>" + // On Windows, Workdir will be like "\<parent_directory>\<owner>\<repo>" + Workdir: filepath.FromSlash(fmt.Sprintf("/%s/%s", r.cfg.Container.WorkdirParent, preset.Repository)), BindWorkdir: false, ReuseContainers: false, |