From 7f72ba9e485b05e546080a1e4ea37e657abc4763 Mon Sep 17 00:00:00 2001 From: eric sciple Date: Wed, 3 Sep 2025 11:45:43 -0500 Subject: [PATCH] Map RUNNER_TEMP for container action (#4011) --- src/Runner.Common/Constants.cs | 1 + src/Runner.Worker/FeatureManager.cs | 5 +++++ src/Runner.Worker/Handlers/ContainerActionHandler.cs | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/src/Runner.Common/Constants.cs b/src/Runner.Common/Constants.cs index 6c288eb2d..f3550842b 100644 --- a/src/Runner.Common/Constants.cs +++ b/src/Runner.Common/Constants.cs @@ -169,6 +169,7 @@ namespace GitHub.Runner.Common public static readonly string AllowRunnerContainerHooks = "DistributedTask.AllowRunnerContainerHooks"; public static readonly string AddCheckRunIdToJobContext = "actions_add_check_run_id_to_job_context"; public static readonly string DisplayHelpfulActionsDownloadErrors = "actions_display_helpful_actions_download_errors"; + public static readonly string ContainerActionRunnerTemp = "actions_container_action_runner_temp"; } // Node version migration related constants diff --git a/src/Runner.Worker/FeatureManager.cs b/src/Runner.Worker/FeatureManager.cs index 98f49e8fd..499995d13 100644 --- a/src/Runner.Worker/FeatureManager.cs +++ b/src/Runner.Worker/FeatureManager.cs @@ -11,5 +11,10 @@ namespace GitHub.Runner.Worker var isContainerHooksPathSet = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(Constants.Hooks.ContainerHooksPath)); return isContainerHookFeatureFlagSet && isContainerHooksPathSet; } + + public static bool IsContainerActionRunnerTempEnabled(Variables variables) + { + return variables?.GetBoolean(Constants.Runner.Features.ContainerActionRunnerTemp) ?? false; + } } } diff --git a/src/Runner.Worker/Handlers/ContainerActionHandler.cs b/src/Runner.Worker/Handlers/ContainerActionHandler.cs index 775ce2f04..b6b080c32 100644 --- a/src/Runner.Worker/Handlers/ContainerActionHandler.cs +++ b/src/Runner.Worker/Handlers/ContainerActionHandler.cs @@ -191,11 +191,19 @@ namespace GitHub.Runner.Worker.Handlers ArgUtil.Directory(tempWorkflowDirectory, nameof(tempWorkflowDirectory)); container.MountVolumes.Add(new MountVolume("/var/run/docker.sock", "/var/run/docker.sock")); + if (FeatureManager.IsContainerActionRunnerTempEnabled(ExecutionContext.Global.Variables)) + { + container.MountVolumes.Add(new MountVolume(tempDirectory, "/github/runner_temp")); + } container.MountVolumes.Add(new MountVolume(tempHomeDirectory, "/github/home")); container.MountVolumes.Add(new MountVolume(tempWorkflowDirectory, "/github/workflow")); container.MountVolumes.Add(new MountVolume(tempFileCommandDirectory, "/github/file_commands")); container.MountVolumes.Add(new MountVolume(defaultWorkingDirectory, "/github/workspace")); + if (FeatureManager.IsContainerActionRunnerTempEnabled(ExecutionContext.Global.Variables)) + { + container.AddPathTranslateMapping(tempDirectory, "/github/runner_temp"); + } container.AddPathTranslateMapping(tempHomeDirectory, "/github/home"); container.AddPathTranslateMapping(tempWorkflowDirectory, "/github/workflow"); container.AddPathTranslateMapping(tempFileCommandDirectory, "/github/file_commands");