diff --git a/pkg/container/container_types.go b/pkg/container/container_types.go index c83ec35b..6b3fc860 100644 --- a/pkg/container/container_types.go +++ b/pkg/container/container_types.go @@ -55,6 +55,7 @@ type Container interface { // NewDockerBuildExecutorInput the input for the NewDockerBuildExecutor function type NewDockerBuildExecutorInput struct { ContextDir string + Dockerfile string Container Container ImageTag string Platform string diff --git a/pkg/container/docker_build.go b/pkg/container/docker_build.go index 0c87cfdf..72150234 100644 --- a/pkg/container/docker_build.go +++ b/pkg/container/docker_build.go @@ -45,12 +45,13 @@ func NewDockerBuildExecutor(input NewDockerBuildExecutorInput) common.Executor { Remove: true, Platform: input.Platform, AuthConfigs: LoadDockerAuthConfigs(ctx), + Dockerfile: input.Dockerfile, } var buildContext io.ReadCloser if input.Container != nil { buildContext, err = input.Container.GetContainerArchive(ctx, input.ContextDir+"/.") } else { - buildContext, err = createBuildContext(ctx, input.ContextDir, "Dockerfile") + buildContext, err = createBuildContext(ctx, input.ContextDir, input.Dockerfile) } if err != nil { return err diff --git a/pkg/runner/action.go b/pkg/runner/action.go index 1da76959..c476ad9f 100644 --- a/pkg/runner/action.go +++ b/pkg/runner/action.go @@ -231,7 +231,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, _ := filepath.Split(filepath.Join(basedir, action.Runs.Image)) + contextDir, fileName := filepath.Split(filepath.Join(basedir, action.Runs.Image)) anyArchExists, err := container.ImageExistsLocally(ctx, image, "any") if err != nil { @@ -261,6 +261,7 @@ func execAsDocker(ctx context.Context, step actionStep, actionName string, based } prepImage = container.NewDockerBuildExecutor(container.NewDockerBuildExecutorInput{ ContextDir: contextDir, + Dockerfile: fileName, ImageTag: image, Container: actionContainer, Platform: rc.Config.ContainerArchitecture, diff --git a/pkg/runner/testdata/actions-environment-and-context-tests/push.yml b/pkg/runner/testdata/actions-environment-and-context-tests/push.yml index db3c3413..1d799d57 100644 --- a/pkg/runner/testdata/actions-environment-and-context-tests/push.yml +++ b/pkg/runner/testdata/actions-environment-and-context-tests/push.yml @@ -11,3 +11,5 @@ jobs: - uses: './actions-environment-and-context-tests/docker' - uses: 'nektos/act-test-actions/js@main' - uses: 'nektos/act-test-actions/docker@main' + - uses: 'nektos/act-test-actions/docker-file@main' + - uses: 'nektos/act-test-actions/docker-relative-context/action@main'