diff --git a/pkg/container/docker_network.go b/pkg/container/docker_network.go index d3a0046..a2305e9 100644 --- a/pkg/container/docker_network.go +++ b/pkg/container/docker_network.go @@ -9,17 +9,14 @@ import ( "github.com/nektos/act/pkg/common" ) -func NewDockerNetworkCreateExecutor(name string) common.Executor { +func NewDockerNetworkCreateExecutor(name string, config *types.NetworkCreate) common.Executor { return func(ctx context.Context) error { cli, err := GetDockerClient(ctx) if err != nil { return err } - _, err = cli.NetworkCreate(ctx, name, types.NetworkCreate{ - Driver: "bridge", - Scope: "local", - }) + _, err = cli.NetworkCreate(ctx, name, *config) if err != nil { return err } diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index 28472d7..e60e4b9 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -21,6 +21,7 @@ import ( "text/template" "time" + docker "github.com/docker/docker/api/types" "github.com/opencontainers/selinux/go-selinux" "github.com/nektos/act/pkg/common" @@ -521,10 +522,15 @@ func (rc *RunContext) startJobContainer() common.Executor { return errors.New("Failed to create job container") } + networkConfig := docker.NetworkCreate{ + Driver: "bridge", + Scope: "local", + EnableIPv6: rc.Config.ContainerNetworkEnableIPv6, + } return common.NewPipelineExecutor( rc.pullServicesImages(rc.Config.ForcePull), rc.JobContainer.Pull(rc.Config.ForcePull), - container.NewDockerNetworkCreateExecutor(networkName).IfBool(!rc.IsHostEnv(ctx) && rc.Config.ContainerNetworkMode == ""), // if the value of `ContainerNetworkMode` is empty string, then will create a new network for containers. + container.NewDockerNetworkCreateExecutor(networkName, &networkConfig).IfBool(!rc.IsHostEnv(ctx) && rc.Config.ContainerNetworkMode == ""), // if the value of `ContainerNetworkMode` is empty string, then will create a new network for containers. rc.startServiceContainers(networkName), rc.JobContainer.Create(rc.Config.ContainerCapAdd, rc.Config.ContainerCapDrop), rc.JobContainer.Start(false), diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index e9f00e2..b6c92e7 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -61,15 +61,16 @@ type Config struct { ReplaceGheActionTokenWithGithubCom string // Token of private action repo on GitHub. Matrix map[string]map[string]bool // Matrix config to run - PresetGitHubContext *model.GithubContext // the preset github context, overrides some fields like DefaultBranch, Env, Secrets etc. - EventJSON string // the content of JSON file to use for event.json in containers, overrides EventPath - ContainerNamePrefix string // the prefix of container name - ContainerMaxLifetime time.Duration // the max lifetime of job containers - ContainerNetworkMode docker_container.NetworkMode // the network mode of job containers (the value of --network) - DefaultActionInstance string // the default actions web site - PlatformPicker func(labels []string) string // platform picker, it will take precedence over Platforms if isn't nil - JobLoggerLevel *log.Level // the level of job logger - ValidVolumes []string // only volumes (and bind mounts) in this slice can be mounted on the job container or service containers + PresetGitHubContext *model.GithubContext // the preset github context, overrides some fields like DefaultBranch, Env, Secrets etc. + EventJSON string // the content of JSON file to use for event.json in containers, overrides EventPath + ContainerNamePrefix string // the prefix of container name + ContainerMaxLifetime time.Duration // the max lifetime of job containers + ContainerNetworkMode docker_container.NetworkMode // the network mode of job containers (the value of --network) + ContainerNetworkEnableIPv6 bool // create the network with IPv6 support enabled + DefaultActionInstance string // the default actions web site + PlatformPicker func(labels []string) string // platform picker, it will take precedence over Platforms if isn't nil + JobLoggerLevel *log.Level // the level of job logger + ValidVolumes []string // only volumes (and bind mounts) in this slice can be mounted on the job container or service containers } // GetToken: Adapt to Gitea