diff --git a/pkg/container/docker_run.go b/pkg/container/docker_run.go index 61b2bfac34a..2b8a59b500d 100644 --- a/pkg/container/docker_run.go +++ b/pkg/container/docker_run.go @@ -699,6 +699,9 @@ func (cr *containerReference) waitForCommand(ctx context.Context, isTerminal boo } func (cr *containerReference) CopyTarStream(ctx context.Context, destPath string, tarStream io.Reader) error { + if common.Dryrun(ctx) { + return nil + } // Mkdir buf := &bytes.Buffer{} tw := tar.NewWriter(buf) diff --git a/pkg/runner/action.go b/pkg/runner/action.go index a19e58f1eb2..0b5feb9fe9f 100644 --- a/pkg/runner/action.go +++ b/pkg/runner/action.go @@ -186,11 +186,11 @@ func runActionImpl(step actionStep, actionDir string, remoteAction *remoteAction return rc.execJobContainer(containerArgs, *step.getEnv(), "", "")(ctx) case model.ActionRunsUsingDocker: - location := actionLocation if remoteAction == nil { - location = containerActionDir + actionDir = "" + actionPath = containerActionDir } - return execAsDocker(ctx, step, actionName, location, remoteAction == nil, "entrypoint") + return execAsDocker(ctx, step, actionName, actionDir, actionPath, remoteAction == nil, "entrypoint") case model.ActionRunsUsingComposite: if err := maybeCopyToActionDir(ctx, step, actionDir, actionPath, containerActionDir); err != nil { return err @@ -243,7 +243,7 @@ func removeGitIgnore(ctx context.Context, directory string) error { // TODO: break out parts of function to reduce complexicity // //nolint:gocyclo -func execAsDocker(ctx context.Context, step actionStep, actionName string, basedir string, localAction bool, entrypointType string) error { +func execAsDocker(ctx context.Context, step actionStep, actionName, basedir, subpath string, localAction bool, entrypointType string) error { logger := common.Logger(ctx) rc := step.getRunContext() action := step.getActionModel() @@ -260,7 +260,7 @@ func execAsDocker(ctx context.Context, step actionStep, actionName string, based image = fmt.Sprintf("%s-dockeraction:%s", regexp.MustCompile("[^a-zA-Z0-9]").ReplaceAllString(actionName, "-"), "latest") image = fmt.Sprintf("act-%s", strings.TrimLeft(image, "-")) image = strings.ToLower(image) - contextDir, fileName := filepath.Split(filepath.Join(basedir, action.Runs.Image)) + contextDir, fileName := path.Split(path.Join(subpath, action.Runs.Image)) anyArchExists, err := container.ImageExistsLocally(ctx, image, "any") if err != nil { @@ -300,7 +300,7 @@ func execAsDocker(ctx context.Context, step actionStep, actionName string, based defer buildContext.Close() } prepImage = container.NewDockerBuildExecutor(container.NewDockerBuildExecutorInput{ - ContextDir: contextDir, + ContextDir: filepath.Join(basedir, contextDir), Dockerfile: fileName, ImageTag: image, BuildContext: buildContext, @@ -557,11 +557,11 @@ func runPreStep(step actionStep) common.Executor { return rc.execJobContainer(containerArgs, *step.getEnv(), "", "")(ctx) case model.ActionRunsUsingDocker: - location := actionLocation if remoteAction == nil { - location = containerActionDir + actionDir = "" + actionPath = containerActionDir } - return execAsDocker(ctx, step, actionName, location, remoteAction == nil, "pre-entrypoint") + return execAsDocker(ctx, step, actionName, actionDir, actionPath, remoteAction == nil, "pre-entrypoint") case model.ActionRunsUsingComposite: if step.getCompositeSteps() == nil { @@ -662,11 +662,11 @@ func runPostStep(step actionStep) common.Executor { return rc.execJobContainer(containerArgs, *step.getEnv(), "", "")(ctx) case model.ActionRunsUsingDocker: - location := actionLocation if remoteAction == nil { - location = containerActionDir + actionDir = "" + actionPath = containerActionDir } - return execAsDocker(ctx, step, actionName, location, remoteAction == nil, "post-entrypoint") + return execAsDocker(ctx, step, actionName, actionDir, actionPath, remoteAction == nil, "post-entrypoint") case model.ActionRunsUsingComposite: if err := maybeCopyToActionDir(ctx, step, actionDir, actionPath, containerActionDir); err != nil {