mirror of
https://github.com/actions/runner.git
synced 2025-12-12 15:13:30 +00:00
Resolve Template Error by Adding ExpressionFunctions
This commit is contained in:
@@ -284,6 +284,9 @@ namespace GitHub.Runner.Worker
|
|||||||
if (token != null)
|
if (token != null)
|
||||||
{
|
{
|
||||||
var templateContext = CreateTemplateContext(executionContext);
|
var templateContext = CreateTemplateContext(executionContext);
|
||||||
|
Trace.Info($"Template context GitHub: {StringUtil.ConvertToJson(templateContext.ExpressionValues["github"])}");
|
||||||
|
|
||||||
|
Trace.Info($"Template context keys: {StringUtil.ConvertToJson(templateContext.ExpressionValues.Keys)}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var evaluateResult = TemplateEvaluator.Evaluate(templateContext, "input-default-context", token, 0, null, omitHeader: true);
|
var evaluateResult = TemplateEvaluator.Evaluate(templateContext, "input-default-context", token, 0, null, omitHeader: true);
|
||||||
|
|||||||
@@ -176,10 +176,17 @@ namespace GitHub.Runner.Worker
|
|||||||
// We need to explitly set the default values of certain things we need like the
|
// We need to explitly set the default values of certain things we need like the
|
||||||
// default repository
|
// default repository
|
||||||
|
|
||||||
if (ExecutionContext.GetGitHubContext("repository") == null)
|
// if (ExecutionContext.GetGitHubContext("repository") == null)
|
||||||
{
|
// {
|
||||||
ExecutionContext.SetGitHubContext("repository", definition.Directory);
|
// ExecutionContext.SetGitHubContext("repository", definition.Directory);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// var githubContext = ExecutionContext.ExpressionValues["github"] as GitHubContext;
|
||||||
|
|
||||||
|
// foreach (var pair in githubContext)
|
||||||
|
// {
|
||||||
|
// ExecutionContext.SetGitHubContext(pair.Key, pair.Value as StringContextData);
|
||||||
|
// }
|
||||||
|
|
||||||
// Merge the default inputs from the definition
|
// Merge the default inputs from the definition
|
||||||
if (definition.Data?.Inputs != null)
|
if (definition.Data?.Inputs != null)
|
||||||
|
|||||||
@@ -5,11 +5,14 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using GitHub.DistributedTask.Expressions2;
|
||||||
using GitHub.DistributedTask.ObjectTemplating.Tokens;
|
using GitHub.DistributedTask.ObjectTemplating.Tokens;
|
||||||
using GitHub.DistributedTask.Pipelines.ContextData;
|
using GitHub.DistributedTask.Pipelines.ContextData;
|
||||||
|
using GitHub.DistributedTask.Pipelines.ObjectTemplating;
|
||||||
using GitHub.DistributedTask.WebApi;
|
using GitHub.DistributedTask.WebApi;
|
||||||
using GitHub.Runner.Common;
|
using GitHub.Runner.Common;
|
||||||
using GitHub.Runner.Sdk;
|
using GitHub.Runner.Sdk;
|
||||||
|
using GitHub.Runner.Worker.Expressions;
|
||||||
using Pipelines = GitHub.DistributedTask.Pipelines;
|
using Pipelines = GitHub.DistributedTask.Pipelines;
|
||||||
|
|
||||||
|
|
||||||
@@ -35,7 +38,7 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
var githubContext = ExecutionContext.ExpressionValues["github"] as GitHubContext;
|
var githubContext = ExecutionContext.ExpressionValues["github"] as GitHubContext;
|
||||||
ArgUtil.NotNull(githubContext, nameof(githubContext));
|
ArgUtil.NotNull(githubContext, nameof(githubContext));
|
||||||
|
|
||||||
Trace.Info($"Github Context: {StringUtil.ConvertToJson(githubContext)}");
|
// Trace.Info($"Github Context: {StringUtil.ConvertToJson(githubContext)}");
|
||||||
|
|
||||||
// Resolve action steps
|
// Resolve action steps
|
||||||
var actionSteps = Data.Steps;
|
var actionSteps = Data.Steps;
|
||||||
@@ -47,6 +50,8 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
inputsData[i.Key] = new StringContextData(i.Value);
|
inputsData[i.Key] = new StringContextData(i.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Trace.Info($"Composite Actions Inputs {StringUtil.ConvertToJson(inputsData)}");
|
||||||
|
|
||||||
// Initialize Composite Steps List of Steps
|
// Initialize Composite Steps List of Steps
|
||||||
var compositeSteps = new List<IStep>();
|
var compositeSteps = new List<IStep>();
|
||||||
|
|
||||||
@@ -78,6 +83,7 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
// Set GITHUB_ACTION_PATH
|
// Set GITHUB_ACTION_PATH
|
||||||
step.ExecutionContext.ExpressionValues["github"] = compositeGitHubContext;
|
step.ExecutionContext.ExpressionValues["github"] = compositeGitHubContext;
|
||||||
step.ExecutionContext.SetGitHubContext("action_path", ActionDirectory);
|
step.ExecutionContext.SetGitHubContext("action_path", ActionDirectory);
|
||||||
|
step.ExecutionContext.ExpressionFunctions.Add(new FunctionInfo<HashFilesFunction>(PipelineTemplateConstants.HashFiles, 1, byte.MaxValue));
|
||||||
|
|
||||||
compositeSteps.Add(step);
|
compositeSteps.Add(step);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user