From 3cd76671dd39ae7e4c647b12e29eac979a1a0b03 Mon Sep 17 00:00:00 2001 From: Erez Testiler Date: Mon, 6 Feb 2023 17:16:38 -0500 Subject: [PATCH] Add support for ghe.com domain (#2420) --- src/Runner.Sdk/Util/UrlUtil.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Runner.Sdk/Util/UrlUtil.cs b/src/Runner.Sdk/Util/UrlUtil.cs index 4e74c9820..2c932e8c1 100644 --- a/src/Runner.Sdk/Util/UrlUtil.cs +++ b/src/Runner.Sdk/Util/UrlUtil.cs @@ -6,9 +6,16 @@ namespace GitHub.Runner.Sdk { public static bool IsHostedServer(UriBuilder gitHubUrl) { - return string.Equals(gitHubUrl.Host, "github.com", StringComparison.OrdinalIgnoreCase) || + if (StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_FORCE_GHES"))) + { + return false; + } + + return + string.Equals(gitHubUrl.Host, "github.com", StringComparison.OrdinalIgnoreCase) || string.Equals(gitHubUrl.Host, "www.github.com", StringComparison.OrdinalIgnoreCase) || - string.Equals(gitHubUrl.Host, "github.localhost", StringComparison.OrdinalIgnoreCase); + string.Equals(gitHubUrl.Host, "github.localhost", StringComparison.OrdinalIgnoreCase) || + gitHubUrl.Host.EndsWith(".ghe.com", StringComparison.OrdinalIgnoreCase); } public static Uri GetCredentialEmbeddedUrl(Uri baseUrl, string username, string password)