diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index f8dedddb..409a2d2c 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -757,15 +757,19 @@ func (rc *RunContext) Executor() (common.Executor, error) { var executor common.Executor var jobType, err = rc.Run.Job().Type() - switch jobType { - case model.JobTypeDefault: - executor = newJobExecutor(rc, &stepFactoryImpl{}, rc) - case model.JobTypeReusableWorkflowLocal: - executor = newLocalReusableWorkflowExecutor(rc) - case model.JobTypeReusableWorkflowRemote: - executor = newRemoteReusableWorkflowExecutor(rc) - case model.JobTypeInvalid: - return nil, err + if exec, ok := rc.Config.CustomExecutor[jobType]; ok { + executor = exec(rc) + } else { + switch jobType { + case model.JobTypeDefault: + executor = newJobExecutor(rc, &stepFactoryImpl{}, rc) + case model.JobTypeReusableWorkflowLocal: + executor = newLocalReusableWorkflowExecutor(rc) + case model.JobTypeReusableWorkflowRemote: + executor = newRemoteReusableWorkflowExecutor(rc) + case model.JobTypeInvalid: + return nil, err + } } return func(ctx context.Context) error { diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index 788dba2d..beadab45 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -66,6 +66,8 @@ type Config struct { ContainerNetworkMode docker_container.NetworkMode // the network mode of job containers (the value of --network) ActionCache ActionCache // Use a custom ActionCache Implementation HostEnvironmentDir string // Custom folder for host environment, parallel jobs must be 1 + + CustomExecutor map[model.JobType]func(*RunContext) common.Executor // Custom executor to run jobs } func (runnerConfig *Config) GetGitHubServerURL() string {