mirror of
https://github.com/actions/runner.git
synced 2025-12-11 21:06:55 +00:00
ah
This commit is contained in:
@@ -135,6 +135,9 @@ namespace GitHub.Runner.Worker
|
|||||||
ExecutionContext.SetGitHubContext("event_path", workflowFile);
|
ExecutionContext.SetGitHubContext("event_path", workflowFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var gitHubActionPath = ExecutionContext.GetGitHubContext("action_path");
|
||||||
|
Trace.Info($"githubactionpath: {gitHubActionPath}");
|
||||||
|
|
||||||
// Setup container stephost for running inside the container.
|
// Setup container stephost for running inside the container.
|
||||||
if (ExecutionContext.Global.Container != null)
|
if (ExecutionContext.Global.Container != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace GitHub.Runner.Worker
|
|||||||
// others
|
// others
|
||||||
void ForceTaskComplete();
|
void ForceTaskComplete();
|
||||||
void RegisterPostJobStep(IStep step);
|
void RegisterPostJobStep(IStep step);
|
||||||
IStep CreateCompositeStep(string scopeName, IActionRunner step, DictionaryContextData inputsData, Dictionary<string, string> envData, string actionDirectory);
|
IStep CreateCompositeStep(string scopeName, IActionRunner step, DictionaryContextData inputsData, Dictionary<string, string> envData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ExecutionContext : RunnerService, IExecutionContext
|
public sealed class ExecutionContext : RunnerService, IExecutionContext
|
||||||
@@ -258,8 +258,7 @@ namespace GitHub.Runner.Worker
|
|||||||
string scopeName,
|
string scopeName,
|
||||||
IActionRunner step,
|
IActionRunner step,
|
||||||
DictionaryContextData inputsData,
|
DictionaryContextData inputsData,
|
||||||
Dictionary<string, string> envData,
|
Dictionary<string, string> envData)
|
||||||
string actionDirectory)
|
|
||||||
{
|
{
|
||||||
step.ExecutionContext = Root.CreateChild(_record.Id, step.DisplayName, _record.Id.ToString("N"), scopeName, step.Action.ContextName, logger: _logger, insideComposite: true, cancellationTokenSource: CancellationTokenSource.CreateLinkedTokenSource(_cancellationTokenSource.Token));
|
step.ExecutionContext = Root.CreateChild(_record.Id, step.DisplayName, _record.Id.ToString("N"), scopeName, step.Action.ContextName, logger: _logger, insideComposite: true, cancellationTokenSource: CancellationTokenSource.CreateLinkedTokenSource(_cancellationTokenSource.Token));
|
||||||
step.ExecutionContext.ExpressionValues["inputs"] = inputsData;
|
step.ExecutionContext.ExpressionValues["inputs"] = inputsData;
|
||||||
@@ -276,9 +275,6 @@ namespace GitHub.Runner.Worker
|
|||||||
envContext[pair.Key] = new StringContextData(pair.Value ?? string.Empty);
|
envContext[pair.Key] = new StringContextData(pair.Value ?? string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add path to action directory as an environment variable.
|
|
||||||
envContext["GITHUB_ACTION_PATH"] = new StringContextData(actionDirectory);
|
|
||||||
|
|
||||||
step.ExecutionContext.ExpressionValues["env"] = envContext;
|
step.ExecutionContext.ExpressionValues["env"] = envContext;
|
||||||
|
|
||||||
return step;
|
return step;
|
||||||
@@ -425,6 +421,7 @@ namespace GitHub.Runner.Worker
|
|||||||
ArgUtil.NotNullOrEmpty(name, nameof(name));
|
ArgUtil.NotNullOrEmpty(name, nameof(name));
|
||||||
var githubContext = ExpressionValues["github"] as GitHubContext;
|
var githubContext = ExpressionValues["github"] as GitHubContext;
|
||||||
githubContext[name] = new StringContextData(value);
|
githubContext[name] = new StringContextData(value);
|
||||||
|
Trace.Info($"GitHub Context: {StringUtil.ConvertToJson(githubContext)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetGitHubContext(string name)
|
public string GetGitHubContext(string name)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace GitHub.Runner.Worker
|
|||||||
private readonly HashSet<string> _contextEnvWhitelist = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
private readonly HashSet<string> _contextEnvWhitelist = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
"action",
|
"action",
|
||||||
|
"action_path",
|
||||||
"actor",
|
"actor",
|
||||||
"api_url",
|
"api_url",
|
||||||
"base_ref",
|
"base_ref",
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
childScopeName = $"__{Guid.NewGuid()}";
|
childScopeName = $"__{Guid.NewGuid()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set GITHUB_ACTION_PATH
|
||||||
|
Trace.Info($"ActionDirectory: {ActionDirectory}");
|
||||||
|
ExecutionContext.SetGitHubContext("action_path", ActionDirectory);
|
||||||
|
|
||||||
foreach (Pipelines.ActionStep actionStep in actionSteps)
|
foreach (Pipelines.ActionStep actionStep in actionSteps)
|
||||||
{
|
{
|
||||||
var actionRunner = HostContext.CreateService<IActionRunner>();
|
var actionRunner = HostContext.CreateService<IActionRunner>();
|
||||||
@@ -63,7 +67,10 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
actionRunner.Stage = stage;
|
actionRunner.Stage = stage;
|
||||||
actionRunner.Condition = actionStep.Condition;
|
actionRunner.Condition = actionStep.Condition;
|
||||||
|
|
||||||
var step = ExecutionContext.CreateCompositeStep(childScopeName, actionRunner, inputsData, Environment, ActionDirectory);
|
var step = ExecutionContext.CreateCompositeStep(childScopeName, actionRunner, inputsData, Environment);
|
||||||
|
|
||||||
|
// step.ExecutionContext.ExpressionValues["github"] = ExecutionContext.ExpressionValues["github"] as GitHubContext;
|
||||||
|
|
||||||
compositeSteps.Add(step);
|
compositeSteps.Add(step);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +184,8 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
var actionStep = step as IActionRunner;
|
var actionStep = step as IActionRunner;
|
||||||
|
|
||||||
// Set GITHUB_ACTION
|
// Set GITHUB_ACTION
|
||||||
step.ExecutionContext.SetGitHubContext("action", step.ExecutionContext.GetFullyQualifiedContextName());
|
// For composite + their nested steps, we want the all of them to have the same GITHUB_ACTION
|
||||||
|
step.ExecutionContext.SetGitHubContext("action", ExecutionContext.GetGitHubContext("action"));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -265,6 +265,11 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
{
|
{
|
||||||
foreach (var env in runtimeContext.GetRuntimeEnvironmentVariables())
|
foreach (var env in runtimeContext.GetRuntimeEnvironmentVariables())
|
||||||
{
|
{
|
||||||
|
if (runtimeContext is GitHubContext)
|
||||||
|
{
|
||||||
|
Trace.Info($"gh context key: {env.Key}");
|
||||||
|
Trace.Info($"gh context Value: {env.Value}");
|
||||||
|
}
|
||||||
Environment[env.Key] = env.Value;
|
Environment[env.Key] = env.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user