mirror of
https://github.com/actions/runner.git
synced 2025-12-11 12:57:05 +00:00
GITHUB_ACTION_PATH + GITHUB_ACTION so that we can run scripts for Composite Run Steps (#615)
* Add environment variable for GITHUB_ACTION_PATH * ah * Remove debugging messages * Set github action path at step level instead of global scope to avoid necessary removal * Remove set context for github action * Set github action path before and after composite action * 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:
@@ -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,14 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
childScopeName = $"__{Guid.NewGuid()}";
|
childScopeName = $"__{Guid.NewGuid()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy the github context so that we don't modify the original pointer
|
||||||
|
// 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)
|
||||||
{
|
{
|
||||||
var actionRunner = HostContext.CreateService<IActionRunner>();
|
var actionRunner = HostContext.CreateService<IActionRunner>();
|
||||||
@@ -64,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +189,6 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
|
|
||||||
var actionStep = step as IActionRunner;
|
var actionStep = step as IActionRunner;
|
||||||
|
|
||||||
// Set GITHUB_ACTION
|
|
||||||
step.ExecutionContext.SetGitHubContext("action", step.ExecutionContext.GetFullyQualifiedContextName());
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Evaluate and merge action's env block to env context
|
// Evaluate and merge action's env block to env context
|
||||||
|
|||||||
Reference in New Issue
Block a user