mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-15 03:36:10 +00:00
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:
@@ -17,6 +17,8 @@ func TestCoerceDispatchInputTypes(t *testing.T) {
|
||||
"build_server": {Type: "boolean"},
|
||||
"dry_run": {Type: "boolean"},
|
||||
"already_bool": {Type: "boolean"},
|
||||
"yaml_true": {Type: "boolean"},
|
||||
"yaml_truthy": {Type: "boolean"},
|
||||
"version": {Type: "string"},
|
||||
},
|
||||
}
|
||||
@@ -27,6 +29,9 @@ func TestCoerceDispatchInputTypes(t *testing.T) {
|
||||
"dry_run": "false",
|
||||
// already-native booleans are passed through unchanged (coercion is idempotent)
|
||||
"already_bool": true,
|
||||
// source text of `default: True` and `default: yes`, only the former is a YAML 1.2 boolean
|
||||
"yaml_true": "True",
|
||||
"yaml_truthy": "yes",
|
||||
// non-boolean inputs must be left untouched
|
||||
"version": "1.2.3",
|
||||
}
|
||||
@@ -38,5 +43,17 @@ func TestCoerceDispatchInputTypes(t *testing.T) {
|
||||
assert.Equal(t, true, inputs["build_server"])
|
||||
assert.Equal(t, false, inputs["dry_run"])
|
||||
assert.Equal(t, true, inputs["already_bool"])
|
||||
assert.Equal(t, true, inputs["yaml_true"])
|
||||
assert.Equal(t, false, inputs["yaml_truthy"])
|
||||
assert.Equal(t, "1.2.3", inputs["version"])
|
||||
|
||||
// `github.event.inputs` mirrors them as normalized strings
|
||||
assert.Equal(t, map[string]any{
|
||||
"build_server": "true",
|
||||
"dry_run": "false",
|
||||
"already_bool": "true",
|
||||
"yaml_true": "true",
|
||||
"yaml_truthy": "false",
|
||||
"version": "1.2.3",
|
||||
}, dispatchEventInputs(inputs))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user