From 3a1376f90e5730118afd356b4aa017add4648b46 Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Fri, 2 Jun 2023 13:01:59 +0200 Subject: [PATCH] Fix `uses: docker://image:tag` steps when container hook is used (#2626) * Fix `uses: docker://image:tag` steps when container hook is used * Update src/Runner.Worker/ActionManager.cs --------- Co-authored-by: Ferenc Hammerl <31069338+fhammerl@users.noreply.github.com> --- src/Runner.Worker/ActionManager.cs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/Runner.Worker/ActionManager.cs b/src/Runner.Worker/ActionManager.cs index 6f7a0cb86..95acbec89 100644 --- a/src/Runner.Worker/ActionManager.cs +++ b/src/Runner.Worker/ActionManager.cs @@ -317,15 +317,28 @@ namespace GitHub.Runner.Worker if (action.Reference.Type == Pipelines.ActionSourceType.ContainerRegistry) { - Trace.Info("Load action that reference container from registry."); - CachedActionContainers.TryGetValue(action.Id, out var container); - ArgUtil.NotNull(container, nameof(container)); - definition.Data.Execution = new ContainerActionExecutionData() + if (FeatureManager.IsContainerHooksEnabled(executionContext.Global.Variables)) { - Image = container.ContainerImage - }; + Trace.Info("Load action that will run container through container hooks."); + var containerAction = action.Reference as Pipelines.ContainerRegistryReference; + definition.Data.Execution = new ContainerActionExecutionData() + { + Image = containerAction.Image, + }; + Trace.Info($"Using action container image: {containerAction.Image}."); + } + else + { + Trace.Info("Load action that reference container from registry."); + CachedActionContainers.TryGetValue(action.Id, out var container); + ArgUtil.NotNull(container, nameof(container)); + definition.Data.Execution = new ContainerActionExecutionData() + { + Image = container.ContainerImage + }; - Trace.Info($"Using action container image: {container.ContainerImage}."); + Trace.Info($"Using action container image: {container.ContainerImage}."); + } } else if (action.Reference.Type == Pipelines.ActionSourceType.Repository) {