Set github action path before and after composite action

This commit is contained in:
Ethan Chiu
2020-07-28 10:46:59 -04:00
parent 4cf17bc51e
commit 1ad181673f
2 changed files with 9 additions and 7 deletions

View File

@@ -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;
@@ -277,9 +276,6 @@ namespace GitHub.Runner.Worker
}
step.ExecutionContext.ExpressionValues["env"] = envContext;
// Set GITHUB_ACTION_PATH for each step
step.ExecutionContext.SetGitHubContext("action_path", actionDirectory);
return step;
}

View File

@@ -56,6 +56,9 @@ namespace GitHub.Runner.Worker.Handlers
childScopeName = $"__{Guid.NewGuid()}";
}
// Add GITHUB_ACTION_PATH
ExecutionContext.SetGitHubContext("action_path", ActionDirectory);
foreach (Pipelines.ActionStep actionStep in actionSteps)
{
var actionRunner = HostContext.CreateService<IActionRunner>();
@@ -63,7 +66,7 @@ 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);
compositeSteps.Add(step);
}
@@ -85,6 +88,9 @@ namespace GitHub.Runner.Worker.Handlers
ExecutionContext.Error(ex);
ExecutionContext.Result = TaskResult.Failed;
}
// Remove GITHUB_ACTION_PATH
ExecutionContext.SetGitHubContext("action_path", "");
}
private void ProcessCompositeActionOutputs()