From f3861e60fc4e53496b423deea91194dc24efd98d Mon Sep 17 00:00:00 2001 From: Mai-Lapyst Date: Sat, 20 Apr 2024 00:18:37 +0200 Subject: [PATCH] Add support for workflow inputs This is a somewhat "hacky" way; it copies the inputs from the "event" object's "inputs" field when the event is a "workflow_dispatch". But this way we do not need to change the protobuf powered runner protocol to also include the inputs. Espc. since they're also present inside the event anyway. --- internal/app/run/runner.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go index ff54fa7..69001d1 100644 --- a/internal/app/run/runner.go +++ b/internal/app/run/runner.go @@ -187,6 +187,13 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. maxLifetime = time.Until(deadline) } + var inputs map[string]string + if preset.EventName == "workflow_dispatch" { + if inputsRaw, ok := preset.Event["inputs"]; ok { + inputs, _ = inputsRaw.(map[string]string) + } + } + runnerConfig := &runner.Config{ // On Linux, Workdir will be like "///" // On Windows, Workdir will be like "\\\" @@ -218,6 +225,7 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. Vars: task.Vars, ValidVolumes: r.cfg.Container.ValidVolumes, InsecureSkipTLS: r.cfg.Runner.Insecure, + Inputs: inputs, } rr, err := runner.New(runnerConfig)