fix(actions): keep github.event.inputs as strings for workflow_dispatch (#38899)

`github.event.inputs` must mirror the raw `workflow_dispatch` payload,
where
GitHub keeps every input as a string. Only the separate `inputs` context
preserves declared types, e.g. booleans. A previous fix coerced boolean
inputs in the single map that fed both contexts, so
`github.event.inputs.someBool` became a real boolean and comparisons
like
`== 'true'` stopped matching.

`github.event.inputs` now stays string-only again. The `inputs` context
used
for server-side `if:` evaluation of needs-gated/matrix-deferred jobs
re-coerces booleans independently, from the job's own workflow
declaration,
so that path keeps working correctly.

Fixes https://github.com/go-gitea/gitea/issues/38896

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
bircni
2026-08-13 09:36:41 +02:00
committed by GitHub
co-authored by Zettat123 silverwind
parent 5287860efb
commit 01e9febbea
13 changed files with 138 additions and 31 deletions
+25 -2
View File
@@ -16,7 +16,8 @@ import (
"gitea.dev/modules/util"
)
func getWorkflowDispatchInputsFromRun(run *actions_model.ActionRun) (map[string]any, error) {
// dispatchInputsForJob types a top-level job's `inputs.*` from EventPayload, empty for other events.
func dispatchInputsForJob(run *actions_model.ActionRun, job *actions_model.ActionRunJob) (map[string]any, error) {
if run.Event != "workflow_dispatch" {
return map[string]any{}, nil
}
@@ -24,15 +25,37 @@ func getWorkflowDispatchInputsFromRun(run *actions_model.ActionRun) (map[string]
if err := json.Unmarshal([]byte(run.EventPayload), &payload); err != nil {
return nil, err
}
if payload.Inputs == nil {
payload.Inputs = map[string]any{} // nil reads as "unresolved" in EvaluateRunConcurrencyFillModel
}
swf, _, err := jobparser.ParseRawSingleWorkflow(job.WorkflowPayload)
if err != nil {
return nil, util.NewInvalidArgumentErrorf("parse job %d workflow payload: %v", job.ID, err)
}
dispatch := swf.WorkflowDispatchConfig()
if dispatch == nil { // without it the values would silently stay untyped
return nil, util.NewInvalidArgumentErrorf("job %d payload declares no workflow_dispatch", job.ID)
}
coerceDispatchInputTypes(dispatch, payload.Inputs)
return payload.Inputs, nil
}
// dispatchInputsForRunJobs answers for the whole run, off any top-level job's workflow header.
func dispatchInputsForRunJobs(run *actions_model.ActionRun, jobs []*actions_model.ActionRunJob) (map[string]any, error) {
for _, job := range jobs {
if job.ParentJobID == 0 {
return dispatchInputsForJob(run, job)
}
}
return nil, fmt.Errorf("run %d: no top-level job to read the workflow_dispatch declaration from", run.ID)
}
// getInputsForJob returns the `inputs.*` top-level expression context for a job's evaluation.
// - For top-level jobs, it falls back to the run's dispatch inputs (empty for non-dispatch events)
// - For reusable workflow children (and nested callers), this is the direct parent caller's CallPayload.Inputs
func getInputsForJob(ctx context.Context, run *actions_model.ActionRun, job *actions_model.ActionRunJob) (map[string]any, error) {
if job.ParentJobID == 0 {
return getWorkflowDispatchInputsFromRun(run)
return dispatchInputsForJob(run, job)
}
caller, err := actions_model.GetRunJobByRunAndID(ctx, run.ID, job.ParentJobID)