Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add github.url and github.api_url for ghes alpha #386

Merged
merged 1 commit into from Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Runner.Worker/GitHubContext.cs
Expand Up @@ -10,6 +10,7 @@ public sealed class GitHubContext : DictionaryContextData, IEnvironmentContextDa
{
"action",
"actor",
"api_url", // temp for GHES alpha release
ericsciple marked this conversation as resolved.
Show resolved Hide resolved
"base_ref",
"event_name",
"event_path",
Expand All @@ -21,6 +22,7 @@ public sealed class GitHubContext : DictionaryContextData, IEnvironmentContextDa
"run_id",
"run_number",
"sha",
"url", // temp for GHES alpha release
"workflow",
"workspace",
};
Expand Down
12 changes: 12 additions & 0 deletions src/Runner.Worker/JobExtension.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
Expand Down Expand Up @@ -127,6 +128,17 @@ public async Task<List<IStep>> InitializeJob(IExecutionContext jobContext, Pipel
context.SetRunnerContext("workspace", Path.Combine(_workDirectory, trackingConfig.PipelineDirectory));
context.SetGitHubContext("workspace", Path.Combine(_workDirectory, trackingConfig.WorkspaceDirectory));

// Temporary hack for GHES alpha
var configurationStore = HostContext.GetService<IConfigurationStore>();
var runnerSettings = configurationStore.GetSettings();
if (!runnerSettings.IsHostedServer && !string.IsNullOrEmpty(runnerSettings.GitHubUrl))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be string.IsNullOrEmpty(runnerSettings.GitHubUrl). This will be non-null if you're talking to hosted GitHub -- see where this is set.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, is that supposed to be an || in the middle?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

@TingluoHuang when !runnerSettings.IsHostedServer should we fallback to runnerSettings.ServerUrl when GitHubUrl is not defined?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runnerSettings.ServerUrl is the pipelines url, pipelines.actions.githubusercontent.com/xxxxx

When GitHubUrl is not defined, it means we connected to Devfabric.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i think the change here might be fine then, but additional change to figure out for registration against the appliance

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed offline w/ ting, leaving this way for now. When config against appliance works, will need an additional change to persist githuburl for that scenario.

{
var url = new Uri(runnerSettings.GitHubUrl);
var portInfo = url.IsDefaultPort ? string.Empty : $":{url.Port.ToString(CultureInfo.InvariantCulture)}";
context.SetGitHubContext("url", $"{url.Scheme}://{url.Host}{portInfo}");
context.SetGitHubContext("api_url", $"{url.Scheme}://api.{url.Host}{portInfo}");
}

// Evaluate the job-level environment variables
context.Debug("Evaluating job-level environment variables");
var templateEvaluator = context.ToPipelineTemplateEvaluator();
Expand Down