mirror of
https://gitea.com/gitea/runner.git
synced 2026-08-27 06:17:45 +00:00
fix: keep a step's own with: values out of its inputs context (#1192)
A step's `if:`, its `continue-on-error:` and its `run:` script resolved `inputs.*` from the step's own `INPUT_*` env. A `with:` key colliding with a workflow input flipped conditions, and any `INPUT_`-shaped variable from `env:` or a `GITHUB_ENV` write forged an input that never existed. GitHub evaluates all three in the enclosing scope: the workflow inputs, or for a composite action's steps that action's inputs. Action-input interpolation is the one place that legitimately sees a step's own `with:`, so it keeps its own evaluator. Fixes https://gitea.com/gitea/runner/issues/1191, ports https://github.com/nektos/act/pull/2473 and extends it to the pre and post stages. --------- Co-authored-by: silverwind <me@silverwind.io> Reviewed-on: https://gitea.com/gitea/runner/pulls/1192 Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com> Co-authored-by: ABiscuitttt <773542570@qq.com>
This commit is contained in:
@@ -62,6 +62,7 @@ type RunContext struct {
|
||||
JobName string
|
||||
ActionPath string
|
||||
Parent *RunContext
|
||||
actionInputs map[string]any // inputs of the composite action this runs, nil for a job
|
||||
Masks []string
|
||||
cleanUpJobContainer common.Executor
|
||||
caller *caller // job calling this RunContext (reusable workflows)
|
||||
@@ -179,6 +180,13 @@ func (rc *RunContext) GetEnv() map[string]string {
|
||||
return rc.Env
|
||||
}
|
||||
|
||||
// setActionEnv sets a composite action's env, keeping the `inputs` context it derives from
|
||||
// in sync. Remote actions re-evaluate it per stage, so inputs may change between them.
|
||||
func (rc *RunContext) setActionEnv(env map[string]string) {
|
||||
rc.Env = env
|
||||
rc.actionInputs = inputsFromEnv(env)
|
||||
}
|
||||
|
||||
func (rc *RunContext) jobContainerName() string {
|
||||
// The job id, never evaluated, keeps two jobs apart when masking collapses their names.
|
||||
nameParts := []string{rc.Config.ContainerNamePrefix, "WORKFLOW-" + rc.Run.Workflow.Name, "JOB-" + rc.Run.JobID, rc.Name}
|
||||
|
||||
Reference in New Issue
Block a user