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

Function newRunCommand

cmd/root.go:391–714  ·  view source on GitHub ↗

nolint:gocyclo

(ctx context.Context, input *Input)

Source from the content-addressed store, hash-verified

389
390//nolint:gocyclo
391func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []string) error {
392 return func(cmd *cobra.Command, args []string) error {
393 if input.jsonLogger {
394 log.SetFormatter(&log.JSONFormatter{})
395 }
396
397 if ok, _ := cmd.Flags().GetBool("bug-report"); ok {
398 ctx, cancel := common.EarlyCancelContext(ctx)
399 defer cancel()
400 return bugReport(ctx, cmd.Version)
401 }
402 if ok, _ := cmd.Flags().GetBool("man-page"); ok {
403 return generateManPage(cmd)
404 }
405 if input.listOptions {
406 return listOptions(cmd)
407 }
408
409 if ret, err := container.GetSocketAndHost(input.containerDaemonSocket); err != nil {
410 log.Warnf("Couldn't get a valid docker connection: %+v", err)
411 } else {
412 os.Setenv("DOCKER_HOST", ret.Host)
413 input.containerDaemonSocket = ret.Socket
414 log.Infof("Using docker host '%s', and daemon socket '%s'", ret.Host, ret.Socket)
415 }
416
417 if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" && input.containerArchitecture == "" {
418 l := log.New()
419 l.SetFormatter(&log.TextFormatter{
420 DisableQuote: true,
421 DisableTimestamp: true,
422 })
423 l.Warnf(" \U000026A0 You are using Apple M-series chip and you have not specified container architecture, you might encounter issues while running act. If so, try running it with '--container-architecture linux/amd64'. \U000026A0 \n")
424 }
425
426 log.Debugf("Loading environment from %s", input.Envfile())
427 envs := parseEnvs(input.envs)
428 _ = readEnvs(input.Envfile(), envs)
429
430 log.Debugf("Loading action inputs from %s", input.Inputfile())
431 inputs := parseEnvs(input.inputs)
432 _ = readEnvs(input.Inputfile(), inputs)
433
434 log.Debugf("Loading secrets from %s", input.Secretfile())
435 secrets := newSecrets(input.secrets)
436 _ = readEnvsEx(input.Secretfile(), secrets, true)
437
438 if _, hasGitHubToken := secrets["GITHUB_TOKEN"]; !hasGitHubToken {
439 ctx, cancel := common.EarlyCancelContext(ctx)
440 defer cancel()
441 secrets["GITHUB_TOKEN"], _ = gh.GetToken(ctx, "")
442 }
443
444 log.Debugf("Loading vars from %s", input.Varfile())
445 vars := newSecrets(input.vars)
446 _ = readEnvs(input.Varfile(), vars)
447
448 matrixes := parseMatrix(input.matrix)

Callers 6

createRootCommandFunction · 0.85
TestListOptionsFunction · 0.85
TestRunFunction · 0.85
TestRunPushFunction · 0.85
TestRunPushJsonLoggerFunction · 0.85
TestFlagsFunction · 0.85

Calls 15

GetEventsMethod · 0.95
PlanJobMethod · 0.95
PlanEventMethod · 0.95
PlanAllMethod · 0.95
ExternalURLMethod · 0.95
CloseMethod · 0.95
EarlyCancelContextFunction · 0.92
GetSocketAndHostFunction · 0.92
GetTokenFunction · 0.92
NewWorkflowPlannerFunction · 0.92
NewFunction · 0.92
ServeFunction · 0.92

Tested by 5

TestListOptionsFunction · 0.68
TestRunFunction · 0.68
TestRunPushFunction · 0.68
TestRunPushJsonLoggerFunction · 0.68
TestFlagsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…