(ctx context.Context, input *Input, version string)
| 54 | } |
| 55 | |
| 56 | func createRootCommand(ctx context.Context, input *Input, version string) *cobra.Command { |
| 57 | rootCmd := &cobra.Command{ |
| 58 | Use: "act [event name to run] [flags]\n\nIf no event name passed, will default to \"on: push\"\nIf actions handles only one event it will be used as default instead of \"on: push\"", |
| 59 | Short: "Run GitHub actions locally by specifying the event name (e.g. `push`) or an action name directly.", |
| 60 | Args: cobra.MaximumNArgs(1), |
| 61 | RunE: newRunCommand(ctx, input), |
| 62 | PersistentPreRun: setup(input), |
| 63 | PersistentPostRun: cleanup(input), |
| 64 | Version: version, |
| 65 | SilenceUsage: true, |
| 66 | } |
| 67 | |
| 68 | rootCmd.Flags().BoolP("watch", "w", false, "watch the contents of the local repo and run when files change") |
| 69 | rootCmd.Flags().BoolVar(&input.validate, "validate", false, "validate workflows") |
| 70 | rootCmd.Flags().BoolVar(&input.strict, "strict", false, "use strict workflow schema") |
| 71 | rootCmd.Flags().BoolP("list", "l", false, "list workflows") |
| 72 | rootCmd.Flags().BoolP("graph", "g", false, "draw workflows") |
| 73 | rootCmd.Flags().StringP("job", "j", "", "run a specific job ID") |
| 74 | rootCmd.Flags().BoolP("bug-report", "", false, "Display system information for bug report") |
| 75 | rootCmd.Flags().BoolP("man-page", "", false, "Print a generated manual page to stdout") |
| 76 | |
| 77 | rootCmd.Flags().StringVar(&input.remoteName, "remote-name", "origin", "git remote name that will be used to retrieve url of git repo") |
| 78 | rootCmd.Flags().StringArrayVarP(&input.secrets, "secret", "s", []string{}, "secret to make available to actions with optional value (e.g. -s mysecret=foo or -s mysecret)") |
| 79 | rootCmd.Flags().StringArrayVar(&input.vars, "var", []string{}, "variable to make available to actions with optional value (e.g. --var myvar=foo or --var myvar)") |
| 80 | rootCmd.Flags().StringArrayVarP(&input.envs, "env", "", []string{}, "env to make available to actions with optional value (e.g. --env myenv=foo or --env myenv)") |
| 81 | rootCmd.Flags().StringArrayVarP(&input.inputs, "input", "", []string{}, "action input to make available to actions (e.g. --input myinput=foo)") |
| 82 | rootCmd.Flags().StringArrayVarP(&input.platforms, "platform", "P", []string{}, "custom image to use per platform (e.g. -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04)") |
| 83 | rootCmd.Flags().BoolVarP(&input.reuseContainers, "reuse", "r", false, "don't remove container(s) on successfully completed workflow(s) to maintain state between runs") |
| 84 | rootCmd.Flags().BoolVarP(&input.bindWorkdir, "bind", "b", false, "bind working directory to container, rather than copy") |
| 85 | rootCmd.Flags().BoolVarP(&input.forcePull, "pull", "p", true, "pull docker image(s) even if already present") |
| 86 | rootCmd.Flags().BoolVarP(&input.forceRebuild, "rebuild", "", true, "rebuild local action docker image(s) even if already present") |
| 87 | rootCmd.Flags().BoolVarP(&input.autodetectEvent, "detect-event", "", false, "Use first event type from workflow as event that triggered the workflow") |
| 88 | rootCmd.Flags().StringVarP(&input.eventPath, "eventpath", "e", "", "path to event JSON file") |
| 89 | rootCmd.Flags().StringVar(&input.defaultBranch, "defaultbranch", "", "the name of the main branch") |
| 90 | rootCmd.Flags().BoolVar(&input.privileged, "privileged", false, "use privileged mode") |
| 91 | rootCmd.Flags().StringVar(&input.usernsMode, "userns", "", "user namespace to use") |
| 92 | rootCmd.Flags().BoolVar(&input.useGitIgnore, "use-gitignore", true, "Controls whether paths specified in .gitignore should be copied into container") |
| 93 | rootCmd.Flags().StringArrayVarP(&input.containerCapAdd, "container-cap-add", "", []string{}, "kernel capabilities to add to the workflow containers (e.g. --container-cap-add SYS_PTRACE)") |
| 94 | rootCmd.Flags().StringArrayVarP(&input.containerCapDrop, "container-cap-drop", "", []string{}, "kernel capabilities to remove from the workflow containers (e.g. --container-cap-drop SYS_PTRACE)") |
| 95 | rootCmd.Flags().BoolVar(&input.autoRemove, "rm", false, "automatically remove container(s)/volume(s) after a workflow(s) failure") |
| 96 | rootCmd.Flags().StringArrayVarP(&input.replaceGheActionWithGithubCom, "replace-ghe-action-with-github-com", "", []string{}, "If you are using GitHub Enterprise Server and allow specified actions from GitHub (github.com), you can set actions on this. (e.g. --replace-ghe-action-with-github-com =github/super-linter)") |
| 97 | rootCmd.Flags().StringVar(&input.replaceGheActionTokenWithGithubCom, "replace-ghe-action-token-with-github-com", "", "If you are using replace-ghe-action-with-github-com and you want to use private actions on GitHub, you have to set personal access token") |
| 98 | rootCmd.Flags().StringArrayVarP(&input.matrix, "matrix", "", []string{}, "specify which matrix configuration to include (e.g. --matrix java:13") |
| 99 | rootCmd.PersistentFlags().StringVarP(&input.actor, "actor", "a", "nektos/act", "user that triggered the event") |
| 100 | rootCmd.PersistentFlags().StringVarP(&input.workflowsPath, "workflows", "W", "./.github/workflows/", "path to workflow file(s)") |
| 101 | rootCmd.PersistentFlags().BoolVarP(&input.noWorkflowRecurse, "no-recurse", "", false, "Flag to disable running workflows from subdirectories of specified path in '--workflows'/'-W' flag") |
| 102 | rootCmd.PersistentFlags().StringVarP(&input.workdir, "directory", "C", ".", "working directory") |
| 103 | rootCmd.PersistentFlags().BoolP("verbose", "v", false, "verbose output") |
| 104 | rootCmd.PersistentFlags().BoolVar(&input.jsonLogger, "json", false, "Output logs in json format") |
| 105 | rootCmd.PersistentFlags().BoolVar(&input.logPrefixJobID, "log-prefix-job-id", false, "Output the job id within non-json logs instead of the entire name") |
| 106 | rootCmd.PersistentFlags().BoolVarP(&input.noOutput, "quiet", "q", false, "disable logging of output from steps") |
| 107 | rootCmd.PersistentFlags().BoolVarP(&input.dryrun, "dryrun", "n", false, "disable container creation, validates only workflow correctness") |
| 108 | rootCmd.PersistentFlags().StringVarP(&input.secretfile, "secret-file", "", ".secrets", "file with list of secrets to read from (e.g. --secret-file .secrets)") |
| 109 | rootCmd.PersistentFlags().StringVarP(&input.varfile, "var-file", "", ".vars", "file with list of vars to read from (e.g. --var-file .vars)") |
| 110 | rootCmd.PersistentFlags().BoolVarP(&input.insecureSecrets, "insecure-secrets", "", false, "NOT RECOMMENDED! Doesn't hide secrets while printing logs.") |
| 111 | rootCmd.PersistentFlags().StringVarP(&input.envfile, "env-file", "", ".env", "environment file to read and use as env in the containers") |
| 112 | rootCmd.PersistentFlags().StringVarP(&input.inputfile, "input-file", "", ".input", "input file to read and use as action input") |
| 113 | rootCmd.PersistentFlags().StringVarP(&input.containerArchitecture, "container-architecture", "", "", "Architecture which should be used to run containers, e.g.: linux/amd64. If not specified, will use host default architecture. Requires Docker server API Version 1.41+. Ignored on earlier Docker server platforms.") |
searching dependent graphs…