Env Flow => Able to get env variables and overwrite current env variables => but it doesn't 'stick'

This commit is contained in:
Ethan Chiu
2020-06-18 15:34:48 -04:00
parent 038e5e2c2e
commit e56b2439b9
7 changed files with 111 additions and 3 deletions

View File

@@ -52,6 +52,32 @@ namespace GitHub.Runner.Worker.Handlers
inputsData[i.Key] = new StringContextData(i.Value);
}
// Set up parent's environment data and then add on composite action environment data
#if OS_WINDOWS
var envData = ExecutionContext.ExpressionValues["env"].Clone() as DictionaryContextData;
#else
var envData = ExecutionContext.ExpressionValues["env"].Clone() as CaseSensitiveDictionaryContextData;
#endif
// Composite action will have already inherited the root env attributes.
// We evaluated the env simimilar to how ContainerActionHandler does it.
if (Data.Environment == null) {
Trace.Info($"Composite Env Mapping Token is null");
} else {
Trace.Info($"Composite Env Mapping Token {Data.Environment}");
}
var extraExpressionValues = new Dictionary<string, PipelineContextData>(StringComparer.OrdinalIgnoreCase);
extraExpressionValues["inputs"] = inputsData;
var manifestManager = HostContext.GetService<IActionManifestManager>();
var evaluatedEnv = manifestManager.EvaluateCompositeActionEnvironment(ExecutionContext, Data.Environment, extraExpressionValues);
foreach (var e in evaluatedEnv)
{
// How to add to EnvironmentContextData
// We need to use IEnvironmentContextData because ScriptHandler uses this type for environment variables
Trace.Info($"Composite Action Env Key: {e.Key}");
Trace.Info($"Composite Action Env Value: {e.Value}");
envData[e.Key] = new StringContextData(e.Value);
}
// Add each composite action step to the front of the queue
var compositeActionSteps = new Queue<IStep>();
foreach (Pipelines.ActionStep aStep in actionSteps)
@@ -94,7 +120,7 @@ namespace GitHub.Runner.Worker.Handlers
// TODO: Do we need to add any context data from the job message?
// (See JobExtension.cs ~line 236)
compositeActionSteps.Enqueue(ExecutionContext.RegisterCompositeStep(actionRunner, inputsData));
compositeActionSteps.Enqueue(ExecutionContext.RegisterCompositeStep(actionRunner, inputsData, envData));
}
ExecutionContext.EnqueueAllCompositeSteps(compositeActionSteps);