summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatâ„¢ <me@hackerc.at>2021-01-15 06:26:01 +0100
committerGitHub <noreply@github.com>2021-01-15 06:26:01 +0100
commit41692c314db80bc427ae9dee24a7316b2c27245e (patch)
tree53067696fbc35171bdba34922d851bf0c040a6fc
parentFix "reference not found" error on checkout (#433) (#471) (diff)
downloadforgejo-act-41692c314db80bc427ae9dee24a7316b2c27245e.tar.xz
forgejo-act-41692c314db80bc427ae9dee24a7316b2c27245e.zip
Add --env flag to pass environment vars without file (#474)
-rw-r--r--cmd/input.go1
-rw-r--r--cmd/root.go11
2 files changed, 12 insertions, 0 deletions
diff --git a/cmd/input.go b/cmd/input.go
index 6ca40e9..808be0e 100644
--- a/cmd/input.go
+++ b/cmd/input.go
@@ -14,6 +14,7 @@ type Input struct {
reuseContainers bool
bindWorkdir bool
secrets []string
+ envs []string
platforms []string
dryrun bool
forcePull bool
diff --git a/cmd/root.go b/cmd/root.go
index 2fa2db4..dc28317 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -37,6 +37,7 @@ func Execute(ctx context.Context, version string) {
rootCmd.Flags().BoolP("graph", "g", false, "draw workflows")
rootCmd.Flags().StringP("job", "j", "", "run job")
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)")
+ rootCmd.Flags().StringArrayVarP(&input.envs, "env", "", []string{}, "env to make available to actions with optional value (e.g. --e myenv=foo or -s myenv)")
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)")
rootCmd.Flags().BoolVarP(&input.reuseContainers, "reuse", "r", false, "reuse action containers to maintain state")
rootCmd.Flags().BoolVarP(&input.bindWorkdir, "bind", "b", false, "bind working directory to container, rather than copy")
@@ -121,6 +122,16 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
return func(cmd *cobra.Command, args []string) error {
log.Debugf("Loading environment from %s", input.Envfile())
envs := make(map[string]string)
+ if input.envs != nil {
+ for _, envVar := range input.envs {
+ e := strings.SplitN(envVar, `=`, 2)
+ if len(e) == 2 {
+ envs[e[0]] = e[1]
+ } else {
+ envs[e[0]] = ""
+ }
+ }
+ }
_ = readEnvs(input.Envfile(), envs)
log.Debugf("Loading secrets from %s", input.Secretfile())