forked from actions/runner
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* call the gh auth token for non azure pipelines workloads * prepend this github_token * fix setting values to empty string, e.g. `-s github_token=` to unset
- Loading branch information
1 parent
f20a07c
commit 59c0337
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using GitHub.Runner.Sdk; | ||
|
||
namespace Runner.Client | ||
{ | ||
public class GhCliAuth { | ||
public static async Task<string> GetToken(string workingDirectory, ITraceWriter trace, CancellationToken token) { | ||
string line = null; | ||
void handleOutput(object s, ProcessDataReceivedEventArgs e) | ||
{ | ||
line ??= e.Data; | ||
} | ||
try { | ||
var gh = WhichUtil.Which("gh", require: false, trace: trace); | ||
if (string.IsNullOrWhiteSpace(gh)) | ||
{ | ||
return null; | ||
} | ||
var ghInvoker = new ProcessInvoker(trace); | ||
ghInvoker.OutputDataReceived += handleOutput; | ||
await ghInvoker.ExecuteAsync(workingDirectory, gh, "auth token", new Dictionary<string, string>(), token); | ||
return line; | ||
} catch { | ||
return null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters