Skip to content

Commit bca18f7

Browse files
authored
Improve logic around decide IsHostedServer. (#4086)
1 parent 1b8efb9 commit bca18f7

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/Runner.Common/ConfigurationStore.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using GitHub.Runner.Sdk;
2-
using System;
1+
using System;
32
using System.IO;
43
using System.Linq;
54
using System.Runtime.Serialization;
65
using System.Text;
76
using System.Threading;
7+
using GitHub.Runner.Sdk;
88

99
namespace GitHub.Runner.Common
1010
{
@@ -64,8 +64,20 @@ public bool IsHostedServer
6464
{
6565
get
6666
{
67-
// Old runners do not have this property. Hosted runners likely don't have this property either.
68-
return _isHostedServer ?? true;
67+
// If the value has been explicitly set, return it.
68+
if (_isHostedServer.HasValue)
69+
{
70+
return _isHostedServer.Value;
71+
}
72+
73+
// Otherwise, try to infer it from the GitHubUrl.
74+
if (!string.IsNullOrEmpty(GitHubUrl))
75+
{
76+
return UrlUtil.IsHostedServer(new UriBuilder(GitHubUrl));
77+
}
78+
79+
// Default to true since Hosted runners likely don't have this property set.
80+
return true;
6981
}
7082

7183
set

0 commit comments

Comments
 (0)