Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass dockerfile to build executor #1606

Merged
merged 3 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/container/container_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/container/docker_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func NewDockerBuildExecutor(input NewDockerBuildExecutorInput) common.Executor {
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)
options.Dockerfile = input.Dockerfile
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only set it here because I wasn't sure what the expectation was when the input.Container was not nil. It would seem cleaner to set it in the above block, but I was worried about changing existing behavior.

Copy link
Contributor

@ChristopherHX ChristopherHX Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input.Container = local action, build context not present outside of the docker container.

Please move it out of the if condition.

Assumes the dockerfile is read from the buildcontext.

}
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion pkg/runner/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: 'artificial-aidan/act-test-actions/docker-file@6e10d41bbdb0919d19847350a7763a580cfa41c8'
- uses: 'artificial-aidan/act-test-actions/docker-relative-context/action@6e10d41bbdb0919d19847350a7763a580cfa41c8'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action tests my previous PR