mirror of
https://github.com/actions/runner.git
synced 2025-12-10 12:36:23 +00:00
ah
This commit is contained in:
@@ -135,6 +135,9 @@ namespace GitHub.Runner.Worker
|
||||
ExecutionContext.SetGitHubContext("event_path", workflowFile);
|
||||
}
|
||||
|
||||
var gitHubActionPath = ExecutionContext.GetGitHubContext("action_path");
|
||||
Trace.Info($"githubactionpath: {gitHubActionPath}");
|
||||
|
||||
// Setup container stephost for running inside the container.
|
||||
if (ExecutionContext.Global.Container != null)
|
||||
{
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace GitHub.Runner.Worker
|
||||
// others
|
||||
void ForceTaskComplete();
|
||||
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
|
||||
@@ -258,8 +258,7 @@ namespace GitHub.Runner.Worker
|
||||
string scopeName,
|
||||
IActionRunner step,
|
||||
DictionaryContextData inputsData,
|
||||
Dictionary<string, string> envData,
|
||||
string actionDirectory)
|
||||
Dictionary<string, string> envData)
|
||||
{
|
||||
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;
|
||||
@@ -276,9 +275,6 @@ namespace GitHub.Runner.Worker
|
||||
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;
|
||||
|
||||
return step;
|
||||
@@ -425,6 +421,7 @@ namespace GitHub.Runner.Worker
|
||||
ArgUtil.NotNullOrEmpty(name, nameof(name));
|
||||
var githubContext = ExpressionValues["github"] as GitHubContext;
|
||||
githubContext[name] = new StringContextData(value);
|
||||
Trace.Info($"GitHub Context: {StringUtil.ConvertToJson(githubContext)}");
|
||||
}
|
||||
|
||||
public string GetGitHubContext(string name)
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace GitHub.Runner.Worker
|
||||
private readonly HashSet<string> _contextEnvWhitelist = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"action",
|
||||
"action_path",
|
||||
"actor",
|
||||
"api_url",
|
||||
"base_ref",
|
||||
|
||||
@@ -56,6 +56,10 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
childScopeName = $"__{Guid.NewGuid()}";
|
||||
}
|
||||
|
||||
// Set GITHUB_ACTION_PATH
|
||||
Trace.Info($"ActionDirectory: {ActionDirectory}");
|
||||
ExecutionContext.SetGitHubContext("action_path", ActionDirectory);
|
||||
|
||||
foreach (Pipelines.ActionStep actionStep in actionSteps)
|
||||
{
|
||||
var actionRunner = HostContext.CreateService<IActionRunner>();
|
||||
@@ -63,7 +67,10 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
actionRunner.Stage = stage;
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -177,7 +184,8 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
var actionStep = step as IActionRunner;
|
||||
|
||||
// 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
|
||||
{
|
||||
|
||||
@@ -265,6 +265,11 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user