From ac6e4b7517636bd0f152075ef6f5849d171b30f8 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Fri, 3 Oct 2025 18:05:12 +0000 Subject: [PATCH] Support `inputs` context when parsing jobs (#143) Reusable workflows or manually triggered workflows may get data from [`inputs` context](https://docs.github.com/en/actions/reference/workflows-and-actions/contexts#inputs-context). For example: ``` name: Build run-name: Build app on ${{ inputs.os }} on: workflow_dispatch: inputs: os: description: Select the OS required: true type: choice options: - windows - linux ... ``` Reviewed-on: https://gitea.com/gitea/act/pulls/143 Reviewed-by: Lunny Xiao Co-authored-by: Zettat123 Co-committed-by: Zettat123 --- pkg/jobparser/jobparser.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/jobparser/jobparser.go b/pkg/jobparser/jobparser.go index 5570ae41..9092d856 100644 --- a/pkg/jobparser/jobparser.go +++ b/pkg/jobparser/jobparser.go @@ -42,7 +42,7 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) { return nil, fmt.Errorf("invalid jobs: %w", err) } - evaluator := NewExpressionEvaluator(exprparser.NewInterpeter(&exprparser.EvaluationEnvironment{Github: pc.gitContext, Vars: pc.vars}, exprparser.Config{})) + evaluator := NewExpressionEvaluator(exprparser.NewInterpeter(&exprparser.EvaluationEnvironment{Github: pc.gitContext, Vars: pc.vars, Inputs: pc.inputs}, exprparser.Config{})) workflow.RunName = evaluator.Interpolate(workflow.RunName) for i, id := range ids { @@ -57,7 +57,7 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) { job.Name = id } job.Strategy.RawMatrix = encodeMatrix(matrix) - evaluator := NewExpressionEvaluator(NewInterpeter(id, origin.GetJob(id), matrix, pc.gitContext, results, pc.vars, nil)) + evaluator := NewExpressionEvaluator(NewInterpeter(id, origin.GetJob(id), matrix, pc.gitContext, results, pc.vars, pc.inputs)) job.Name = nameWithMatrix(job.Name, matrix, evaluator) runsOn := origin.GetJob(id).RunsOn() for i, v := range runsOn { @@ -99,10 +99,17 @@ func WithVars(vars map[string]string) ParseOption { } } +func WithInputs(inputs map[string]any) ParseOption { + return func(c *parseContext) { + c.inputs = inputs + } +} + type parseContext struct { jobResults map[string]string gitContext *model.GithubContext vars map[string]string + inputs map[string]any } type ParseOption func(c *parseContext)