From f61dcad5bb126b028385764a87ef121e7416d5e5 Mon Sep 17 00:00:00 2001 From: Ferenc Hammerl <31069338+fhammerl@users.noreply.github.com> Date: Mon, 30 Aug 2021 11:52:12 +0200 Subject: [PATCH] Don't try to login to ghcr.io with GHES tokens (#1291) * Don't try GHXX tokens for ghcr.io login * Explain hosted / onpremise in comment * Nitfix variable name --- src/Runner.Listener/Configuration/ConfigurationManager.cs | 1 + src/Runner.Worker/ContainerOperationProvider.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Runner.Listener/Configuration/ConfigurationManager.cs b/src/Runner.Listener/Configuration/ConfigurationManager.cs index ae4f8ad33..e50101591 100644 --- a/src/Runner.Listener/Configuration/ConfigurationManager.cs +++ b/src/Runner.Listener/Configuration/ConfigurationManager.cs @@ -117,6 +117,7 @@ namespace GitHub.Runner.Listener.Configuration try { // Determine the service deployment type based on connection data. (Hosted/OnPremises) + // Hosted usually means github.com or localhost, while OnPremises means GHES or GHAE runnerSettings.IsHostedServer = runnerSettings.GitHubUrl == null || UrlUtil.IsHostedServer(new UriBuilder(runnerSettings.GitHubUrl)); // Warn if the Actions server url and GHES server url has different Host diff --git a/src/Runner.Worker/ContainerOperationProvider.cs b/src/Runner.Worker/ContainerOperationProvider.cs index f8ce2bc04..1a57c393e 100644 --- a/src/Runner.Worker/ContainerOperationProvider.cs +++ b/src/Runner.Worker/ContainerOperationProvider.cs @@ -494,7 +494,8 @@ namespace GitHub.Runner.Worker private void UpdateRegistryAuthForGitHubToken(IExecutionContext executionContext, ContainerInfo container) { var registryIsTokenCompatible = container.RegistryServer.Equals("ghcr.io", StringComparison.OrdinalIgnoreCase) || container.RegistryServer.Equals("containers.pkg.github.com", StringComparison.OrdinalIgnoreCase); - if (!registryIsTokenCompatible) + var isFallbackTokenFromHostedGithub = HostContext.GetService().GetSettings().IsHostedServer; + if (!registryIsTokenCompatible || !isFallbackTokenFromHostedGithub) { return; }