Fix failed to create container if the runner works in root dir (#67)

Fix #56

This PR uses the `preset.Repository` as a part of the workdir and use `filepath.FromSlash` to convert the slash characters.

Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/67
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>
This commit is contained in:
Zettat123 2023-03-23 09:41:22 +08:00 committed by Jason Song
parent 9f90cba993
commit 8f81f40d62
1 changed files with 3 additions and 1 deletions

View File

@ -212,7 +212,9 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task, runnerName, runnerV
input := t.Input input := t.Input
config := &runner.Config{ config := &runner.Config{
Workdir: "." + string(filepath.Separator), // On Linux, Workdir will be like "/<owner>/<repo>"
// On Windows, Workdir will be like "\<owner>\<repo>"
Workdir: filepath.FromSlash(string(filepath.Separator) + preset.Repository),
BindWorkdir: false, BindWorkdir: false,
ReuseContainers: false, ReuseContainers: false,
ForcePull: input.forcePull, ForcePull: input.forcePull,