-
Notifications
You must be signed in to change notification settings - Fork 877
/
GitHubContext.cs
41 lines (39 loc) · 1.23 KB
/
GitHubContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using GitHub.DistributedTask.Pipelines.ContextData;
using System;
using System.Collections.Generic;
namespace GitHub.Runner.Worker
{
public sealed class GitHubContext : DictionaryContextData, IEnvironmentContextData
{
private readonly HashSet<string> _contextEnvWhitelist = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"action",
"actor",
"api_url", // temp for GHES alpha release
"base_ref",
"event_name",
"event_path",
"head_ref",
"job",
"ref",
"repository",
"repository_owner",
"run_id",
"run_number",
"sha",
"url", // temp for GHES alpha release
"workflow",
"workspace",
};
public IEnumerable<KeyValuePair<string, string>> GetRuntimeEnvironmentVariables()
{
foreach (var data in this)
{
if (_contextEnvWhitelist.Contains(data.Key) && data.Value is StringContextData value)
{
yield return new KeyValuePair<string, string>($"GITHUB_{data.Key.ToUpperInvariant()}", value);
}
}
}
}
}