MCPcopy
hub / github.com/nektos/act / startJobContainer

Method startJobContainer

pkg/runner/run_context.go:255–437  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

253}
254
255func (rc *RunContext) startJobContainer() common.Executor {
256 return func(ctx context.Context) error {
257 logger := common.Logger(ctx)
258 image := rc.platformImage(ctx)
259 rawLogger := logger.WithField("raw_output", true)
260 logWriter := common.NewLineWriter(rc.commandHandler(ctx), func(s string) bool {
261 if rc.Config.LogOutput {
262 rawLogger.Infof("%s", s)
263 } else {
264 rawLogger.Debugf("%s", s)
265 }
266 return true
267 })
268
269 username, password, err := rc.handleCredentials(ctx)
270 if err != nil {
271 return fmt.Errorf("failed to handle credentials: %s", err)
272 }
273
274 logger.Infof("\U0001f680 Start image=%s", image)
275 name := rc.jobContainerName()
276
277 envList := make([]string, 0)
278
279 envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TOOL_CACHE", "/opt/hostedtoolcache"))
280 envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_OS", "Linux"))
281 envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_ARCH", container.RunnerArch(ctx)))
282 envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TEMP", "/tmp"))
283 envList = append(envList, fmt.Sprintf("%s=%s", "LANG", "C.UTF-8")) // Use same locale as GitHub Actions
284
285 ext := container.LinuxContainerEnvironmentExtensions{}
286 binds, mounts := rc.GetBindsAndMounts()
287
288 // specify the network to which the container will connect when `docker create` stage. (like execute command line: docker create --network <networkName> <image>)
289 // if using service containers, will create a new network for the containers.
290 // and it will be removed after at last.
291 networkName, createAndDeleteNetwork := rc.networkName()
292
293 // add service containers
294 for serviceID, spec := range rc.Run.Job().Services {
295 // interpolate env
296 interpolatedEnvs := make(map[string]string, len(spec.Env))
297 for k, v := range spec.Env {
298 interpolatedEnvs[k] = rc.ExprEval.Interpolate(ctx, v)
299 }
300 envs := make([]string, 0, len(interpolatedEnvs))
301 for k, v := range interpolatedEnvs {
302 envs = append(envs, fmt.Sprintf("%s=%s", k, v))
303 }
304 username, password, err = rc.handleServiceCredentials(ctx, spec.Credentials)
305 if err != nil {
306 return fmt.Errorf("failed to handle service %s credentials: %w", serviceID, err)
307 }
308
309 interpolatedVolumes := make([]string, 0, len(spec.Volumes))
310 for _, volume := range spec.Volumes {
311 interpolatedVolumes = append(interpolatedVolumes, rc.ExprEval.Interpolate(ctx, volume))
312 }

Callers 1

startContainerMethod · 0.95

Calls 15

platformImageMethod · 0.95
commandHandlerMethod · 0.95
handleCredentialsMethod · 0.95
jobContainerNameMethod · 0.95
GetBindsAndMountsMethod · 0.95
networkNameMethod · 0.95
ToContainerPathMethod · 0.95
stopServiceContainersMethod · 0.95
containerImageMethod · 0.95
optionsMethod · 0.95

Tested by

no test coverage detected