mirror of
https://github.com/actions/runner.git
synced 2025-12-11 12:57:05 +00:00
Display GITHUB_TOKEN permissions (#966)
* Display GITHUB TOKEN permissions * Display permission list is best effort * Remove newtonsoft dependency
This commit is contained in:
@@ -122,6 +122,26 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var tokenPermissions = jobContext.Global.Variables.Get("system.github.token.permissions") ?? "";
|
||||||
|
if (!string.IsNullOrEmpty(tokenPermissions))
|
||||||
|
{
|
||||||
|
context.Output($"##[group]GITHUB_TOKEN Permissions");
|
||||||
|
var permissions = StringUtil.ConvertFromJson<Dictionary<string, string>>(tokenPermissions);
|
||||||
|
foreach(KeyValuePair<string, string> entry in permissions)
|
||||||
|
{
|
||||||
|
context.Output($"{entry.Key}: {entry.Value}");
|
||||||
|
}
|
||||||
|
context.Output("##[endgroup]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
context.Output($"Fail to parse and display GITHUB_TOKEN permissions list: {ex.Message}");
|
||||||
|
Trace.Error(ex);
|
||||||
|
}
|
||||||
|
|
||||||
var repoFullName = context.GetGitHubContext("repository");
|
var repoFullName = context.GetGitHubContext("repository");
|
||||||
ArgUtil.NotNull(repoFullName, nameof(repoFullName));
|
ArgUtil.NotNull(repoFullName, nameof(repoFullName));
|
||||||
context.Debug($"Primary repository: {repoFullName}");
|
context.Debug($"Primary repository: {repoFullName}");
|
||||||
|
|||||||
Reference in New Issue
Block a user