Skip to content

Commit

Permalink
add run command env options to svc (#191)
Browse files Browse the repository at this point in the history
* add run command env options to svc

* also remove the input env keys
  • Loading branch information
ChristopherHX authored Oct 13, 2024
1 parent 8d74b24 commit 859b906
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"os/signal"
"runtime"
"strings"
"syscall"

"github.com/ChristopherHX/github-act-runner/actionsdotnetactcompat"
Expand Down Expand Up @@ -144,6 +145,13 @@ func (run *RunRunner) RunWithContext(listenerctx context.Context, ctx context.Co
fmt.Printf("settings.json is corrupted: %v, please reconfigure the runner\n", err.Error())
return 1
}
// Clean up our env to not share it with untrusted subprocesses
for _, kv := range os.Environ() {
if strings.HasPrefix(kv, "ACTIONS_RUNNER_INPUT_") {
k, _, _ := strings.Cut(kv, "=")
os.Unsetenv(k)
}
}
runner := &actionsrunner.RunRunner{
Once: run.Once,
Trace: run.Trace,
Expand Down Expand Up @@ -183,7 +191,22 @@ type RunRunnerSvc struct {
}

func (svc *RunRunnerSvc) Start(s service.Service) error {
runner := &RunRunner{}
runner := &RunRunner{
JITConfig: os.Getenv("ACTIONS_RUNNER_INPUT_JITCONFIG"),
Terminal: true,
}
if workerArgs, ok := os.LookupEnv("ACTIONS_RUNNER_INPUT_WORKER_ARGS"); ok {
runner.WorkerArgs = strings.Split(workerArgs, ",")
}
if once, ok := common.LookupEnvBool("ACTIONS_RUNNER_INPUT_ONCE"); ok {
runner.Once = once
}
if trace, ok := common.LookupEnvBool("ACTIONS_RUNNER_INPUT_TRACE"); ok {
runner.Trace = trace
}
if terminal, ok := common.LookupEnvBool("ACTIONS_RUNNER_INPUT_TERMINAL"); ok {
runner.Terminal = terminal
}

ctx, cancel := context.WithCancel(context.Background())
listenerctx, cancelListener := context.WithCancel(context.Background())
Expand Down

0 comments on commit 859b906

Please sign in to comment.