mirror of
https://github.com/actions/runner.git
synced 2025-12-12 05:37:01 +00:00
Copy GitHub Context, use this copied context for each composit step, and then set the action_path for each one (to avoid stamping over parent pointer GitHubContext
This commit is contained in:
@@ -56,8 +56,13 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
childScopeName = $"__{Guid.NewGuid()}";
|
childScopeName = $"__{Guid.NewGuid()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add GITHUB_ACTION_PATH
|
// Copy the github context so that we don't modify the original pointer
|
||||||
ExecutionContext.SetGitHubContext("action_path", ActionDirectory);
|
// We can't use PipelineContextData.Clone() since that creates a null pointer exception for copying a GitHubContext
|
||||||
|
var compositeGitHubContext = new GitHubContext();
|
||||||
|
foreach (var pair in githubContext)
|
||||||
|
{
|
||||||
|
compositeGitHubContext[pair.Key] = pair.Value;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Pipelines.ActionStep actionStep in actionSteps)
|
foreach (Pipelines.ActionStep actionStep in actionSteps)
|
||||||
{
|
{
|
||||||
@@ -67,6 +72,11 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
actionRunner.Condition = actionStep.Condition;
|
actionRunner.Condition = actionStep.Condition;
|
||||||
|
|
||||||
var step = ExecutionContext.CreateCompositeStep(childScopeName, actionRunner, inputsData, Environment);
|
var step = ExecutionContext.CreateCompositeStep(childScopeName, actionRunner, inputsData, Environment);
|
||||||
|
|
||||||
|
// Set GITHUB_ACTION_PATH
|
||||||
|
step.ExecutionContext.ExpressionValues["github"] = compositeGitHubContext;
|
||||||
|
step.ExecutionContext.SetGitHubContext("action_path", ActionDirectory);
|
||||||
|
|
||||||
compositeSteps.Add(step);
|
compositeSteps.Add(step);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,9 +98,6 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
ExecutionContext.Error(ex);
|
ExecutionContext.Error(ex);
|
||||||
ExecutionContext.Result = TaskResult.Failed;
|
ExecutionContext.Result = TaskResult.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove GITHUB_ACTION_PATH
|
|
||||||
ExecutionContext.SetGitHubContext("action_path", "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessCompositeActionOutputs()
|
private void ProcessCompositeActionOutputs()
|
||||||
|
|||||||
Reference in New Issue
Block a user