Skip to content

Commit 3f1dd45

Browse files
Set ACTIONS_ORCHESTRATION_ID as env to actions. (#4178)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
1 parent cf8f50b commit 3f1dd45

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

src/Runner.Common/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public static class Features
172172
public static readonly string SnapshotPreflightHostedRunnerCheck = "actions_snapshot_preflight_hosted_runner_check";
173173
public static readonly string SnapshotPreflightImageGenPoolCheck = "actions_snapshot_preflight_image_gen_pool_check";
174174
public static readonly string CompareWorkflowParser = "actions_runner_compare_workflow_parser";
175+
public static readonly string SetOrchestrationIdEnvForActions = "actions_set_orchestration_id_env_for_actions";
175176
}
176177

177178
// Node version migration related constants

src/Runner.Worker/Handlers/ContainerActionHandler.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ public async Task RunAsync(ActionRunStage stage)
239239
Environment["ACTIONS_RESULTS_URL"] = resultsUrl;
240240
}
241241

242+
if (ExecutionContext.Global.Variables.GetBoolean(Constants.Runner.Features.SetOrchestrationIdEnvForActions) ?? false)
243+
{
244+
if (ExecutionContext.Global.Variables.TryGetValue(Constants.Variables.System.OrchestrationId, out var orchestrationId) && !string.IsNullOrEmpty(orchestrationId))
245+
{
246+
Environment["ACTIONS_ORCHESTRATION_ID"] = orchestrationId;
247+
}
248+
}
249+
242250
foreach (var variable in this.Environment)
243251
{
244252
container.ContainerEnvironmentVariables[variable.Key] = container.TranslateToContainerPath(variable.Value);

src/Runner.Worker/Handlers/NodeScriptActionHandler.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ public async Task RunAsync(ActionRunStage stage)
7777
Environment["ACTIONS_CACHE_SERVICE_V2"] = bool.TrueString;
7878
}
7979

80+
if (ExecutionContext.Global.Variables.GetBoolean(Constants.Runner.Features.SetOrchestrationIdEnvForActions) ?? false)
81+
{
82+
if (ExecutionContext.Global.Variables.TryGetValue(Constants.Variables.System.OrchestrationId, out var orchestrationId) && !string.IsNullOrEmpty(orchestrationId))
83+
{
84+
Environment["ACTIONS_ORCHESTRATION_ID"] = orchestrationId;
85+
}
86+
}
87+
8088
// Resolve the target script.
8189
string target = null;
8290
if (stage == ActionRunStage.Main)

src/Runner.Worker/Handlers/ScriptHandler.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,14 @@ public async Task RunAsync(ActionRunStage stage)
318318
Environment["ACTIONS_ID_TOKEN_REQUEST_TOKEN"] = systemConnection.Authorization.Parameters[EndpointAuthorizationParameters.AccessToken];
319319
}
320320

321+
if (ExecutionContext.Global.Variables.GetBoolean(Constants.Runner.Features.SetOrchestrationIdEnvForActions) ?? false)
322+
{
323+
if (ExecutionContext.Global.Variables.TryGetValue(Constants.Variables.System.OrchestrationId, out var orchestrationId) && !string.IsNullOrEmpty(orchestrationId))
324+
{
325+
Environment["ACTIONS_ORCHESTRATION_ID"] = orchestrationId;
326+
}
327+
}
328+
321329
ExecutionContext.Debug($"{fileName} {arguments}");
322330

323331
Inputs.TryGetValue("standardInInput", out var standardInInput);

0 commit comments

Comments
 (0)