mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-16 01:43:24 +09: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:
co-authored by
Zettat123
silverwind
parent
5287860efb
commit
01e9febbea
@@ -10,6 +10,7 @@ import (
|
||||
act_model "gitea.dev/actionslib/pkg/model"
|
||||
actions_model "gitea.dev/models/actions"
|
||||
"gitea.dev/modules/actions/jobparser"
|
||||
"gitea.dev/modules/setting"
|
||||
|
||||
"go.yaml.in/yaml/v4"
|
||||
)
|
||||
@@ -17,6 +18,7 @@ import (
|
||||
// EvaluateRunConcurrencyFillModel evaluates the expressions in a run-level (workflow) concurrency,
|
||||
// and fills the run attempt model with the evaluated `concurrency.group` and `concurrency.cancel-in-progress` values.
|
||||
// Workflow-level concurrency doesn't depend on the job outputs, so it can always be evaluated if there is no syntax error.
|
||||
// Callers must resolve `inputs`, there is no job in scope here to read `on: workflow_dispatch` from.
|
||||
// See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#concurrency
|
||||
func EvaluateRunConcurrencyFillModel(ctx context.Context, run *actions_model.ActionRun, attempt *actions_model.ActionRunAttempt, wfRawConcurrency *act_model.RawConcurrency, vars map[string]string, inputs map[string]any) error {
|
||||
if err := run.LoadAttributes(ctx); err != nil {
|
||||
@@ -26,11 +28,10 @@ func EvaluateRunConcurrencyFillModel(ctx context.Context, run *actions_model.Act
|
||||
actionsRunCtx := GenerateGiteaContext(ctx, run, attempt, nil)
|
||||
jobResults := map[string]*jobparser.JobResult{"": {}}
|
||||
if inputs == nil {
|
||||
var err error
|
||||
inputs, err = getWorkflowDispatchInputsFromRun(run)
|
||||
if err != nil {
|
||||
return fmt.Errorf("get inputs: %w", err)
|
||||
if run.Event == "workflow_dispatch" {
|
||||
setting.PanicInDevOrTesting("run %d: workflow_dispatch inputs must be resolved by the caller", run.ID)
|
||||
}
|
||||
inputs = map[string]any{}
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
Reference in New Issue
Block a user