diff --git a/pkg/jobparser/interpeter.go b/pkg/jobparser/interpeter.go index 750f9646..8aaf3196 100644 --- a/pkg/jobparser/interpeter.go +++ b/pkg/jobparser/interpeter.go @@ -15,6 +15,7 @@ func NewInterpeter( matrix map[string]interface{}, gitCtx *model.GithubContext, results map[string]*JobResult, + vars map[string]string, ) exprparser.Interpreter { strategy := make(map[string]interface{}) if job.Strategy != nil { @@ -62,6 +63,7 @@ func NewInterpeter( Matrix: matrix, Needs: using, Inputs: nil, // not supported yet + Vars: vars, } config := exprparser.Config{ diff --git a/pkg/jobparser/jobparser.go b/pkg/jobparser/jobparser.go index cd846518..7b3a281b 100644 --- a/pkg/jobparser/jobparser.go +++ b/pkg/jobparser/jobparser.go @@ -53,7 +53,7 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) { } job.Name = nameWithMatrix(job.Name, matrix) job.Strategy.RawMatrix = encodeMatrix(matrix) - evaluator := NewExpressionEvaluator(NewInterpeter(id, origin.GetJob(id), matrix, pc.gitContext, results)) + evaluator := NewExpressionEvaluator(NewInterpeter(id, origin.GetJob(id), matrix, pc.gitContext, results, pc.vars)) runsOn := origin.GetJob(id).RunsOn() for i, v := range runsOn { runsOn[i] = evaluator.Interpolate(v) @@ -86,9 +86,16 @@ func WithGitContext(context *model.GithubContext) ParseOption { } } +func WithVars(vars map[string]string) ParseOption { + return func(c *parseContext) { + c.vars = vars + } +} + type parseContext struct { jobResults map[string]string gitContext *model.GithubContext + vars map[string]string } type ParseOption func(c *parseContext)