mirror of
https://github.com/actions/runner.git
synced 2025-12-10 20:36:49 +00:00
Figure out how to handle set-env edge cases
This commit is contained in:
@@ -105,7 +105,6 @@ namespace GitHub.Runner.Worker
|
|||||||
// others
|
// others
|
||||||
void ForceTaskComplete();
|
void ForceTaskComplete();
|
||||||
void RegisterPostJobStep(IStep step);
|
void RegisterPostJobStep(IStep step);
|
||||||
public void SetEnvironmentVariables(Dictionary<string, string> dict);
|
|
||||||
void RegisterNestedStep(IStep step, DictionaryContextData inputsData, int location, Dictionary<string, string> envData);
|
void RegisterNestedStep(IStep step, DictionaryContextData inputsData, int location, Dictionary<string, string> envData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,13 +280,19 @@ namespace GitHub.Runner.Worker
|
|||||||
// Add the composite action environment variables to each step.
|
// Add the composite action environment variables to each step.
|
||||||
// If the key already exists, we override it since the composite action env variables will have higher precedence
|
// If the key already exists, we override it since the composite action env variables will have higher precedence
|
||||||
// Note that for each composite action step, it's environment variables will be set in the StepRunner automatically
|
// Note that for each composite action step, it's environment variables will be set in the StepRunner automatically
|
||||||
step.ExecutionContext.SetEnvironmentVariables(envData);
|
// step.ExecutionContext.SetEnvironmentVariables(envData);
|
||||||
Root.JobSteps.Insert(location, step);
|
#if OS_WINDOWS
|
||||||
}
|
var envContext = new DictionaryContextData();
|
||||||
|
#else
|
||||||
|
var envContext = new CaseSensitiveDictionaryContextData();
|
||||||
|
#endif
|
||||||
|
foreach (var pair in envData)
|
||||||
|
{
|
||||||
|
envContext[pair.Key] = new StringContextData(pair.Value ?? string.Empty);
|
||||||
|
}
|
||||||
|
step.ExecutionContext.ExpressionValues["env"] = envContext;
|
||||||
|
|
||||||
public void SetEnvironmentVariables(Dictionary<string, string> dict)
|
Root.JobSteps.Insert(location, step);
|
||||||
{
|
|
||||||
this.EnvironmentVariables = dict;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IExecutionContext CreateChild(Guid recordId, string displayName, string refName, string scopeName, string contextName, Dictionary<string, string> intraActionState = null, int? recordOrder = null)
|
public IExecutionContext CreateChild(Guid recordId, string displayName, string refName, string scopeName, string contextName, Dictionary<string, string> intraActionState = null, int? recordOrder = null)
|
||||||
|
|||||||
@@ -93,12 +93,28 @@ namespace GitHub.Runner.Worker
|
|||||||
#else
|
#else
|
||||||
var envContext = new CaseSensitiveDictionaryContextData();
|
var envContext = new CaseSensitiveDictionaryContextData();
|
||||||
#endif
|
#endif
|
||||||
step.ExecutionContext.ExpressionValues["env"] = envContext;
|
// Global env
|
||||||
foreach (var pair in step.ExecutionContext.EnvironmentVariables)
|
foreach (var pair in step.ExecutionContext.EnvironmentVariables)
|
||||||
{
|
{
|
||||||
envContext[pair.Key] = new StringContextData(pair.Value ?? string.Empty);
|
envContext[pair.Key] = new StringContextData(pair.Value ?? string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stomps over with outside step env
|
||||||
|
if (step.ExecutionContext.ExpressionValues.TryGetValue("env", out var envContextData))
|
||||||
|
{
|
||||||
|
#if OS_WINDOWS
|
||||||
|
var dict = envContextData as DictionaryContextData;
|
||||||
|
#else
|
||||||
|
var dict = envContextData as CaseSensitiveDictionaryContextData;
|
||||||
|
#endif
|
||||||
|
foreach (var pair in dict)
|
||||||
|
{
|
||||||
|
envContext[pair.Key] = pair.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
step.ExecutionContext.ExpressionValues["env"] = envContext;
|
||||||
|
|
||||||
bool evaluateStepEnvFailed = false;
|
bool evaluateStepEnvFailed = false;
|
||||||
if (step is IActionRunner actionStep)
|
if (step is IActionRunner actionStep)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user