From c8890d0f3f64b5ed79e619623a66e2c2f3351adf Mon Sep 17 00:00:00 2001 From: Tingluo Huang Date: Thu, 12 Mar 2020 20:47:25 -0400 Subject: [PATCH] Expose job name as $GITHUB_JOB (#366) --- src/Runner.Worker/ExecutionContext.cs | 5 +++++ src/Runner.Worker/GitHubContext.cs | 1 + 2 files changed, 6 insertions(+) diff --git a/src/Runner.Worker/ExecutionContext.cs b/src/Runner.Worker/ExecutionContext.cs index 22e1226ab..d390a9e86 100644 --- a/src/Runner.Worker/ExecutionContext.cs +++ b/src/Runner.Worker/ExecutionContext.cs @@ -599,8 +599,13 @@ namespace GitHub.Runner.Worker var githubAccessToken = new StringContextData(Variables.Get("system.github.token")); var base64EncodedToken = Convert.ToBase64String(Encoding.UTF8.GetBytes($"x-access-token:{githubAccessToken}")); HostContext.SecretMasker.AddValue(base64EncodedToken); + var githubJob = Variables.Get("system.github.job"); var githubContext = new GitHubContext(); githubContext["token"] = githubAccessToken; + if (!string.IsNullOrEmpty(githubJob)) + { + githubContext["job"] = new StringContextData(githubJob); + } var githubDictionary = ExpressionValues["github"].AssertDictionary("github"); foreach (var pair in githubDictionary) { diff --git a/src/Runner.Worker/GitHubContext.cs b/src/Runner.Worker/GitHubContext.cs index 0316fad85..454f5e211 100644 --- a/src/Runner.Worker/GitHubContext.cs +++ b/src/Runner.Worker/GitHubContext.cs @@ -14,6 +14,7 @@ namespace GitHub.Runner.Worker "event_name", "event_path", "head_ref", + "job", "ref", "repository", "run_id",