From 41b03b581c7aec251d96e9a5ea27009542a798d4 Mon Sep 17 00:00:00 2001 From: hackercat Date: Thu, 18 Mar 2021 01:14:08 +0100 Subject: [PATCH] fix: add `ImageOS` env var based on running platform (#571) --- pkg/runner/run_context.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index 8fb427f..82aae31 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -576,8 +576,8 @@ func (rc *RunContext) withGithubEnv(env map[string]string) map[string]string { github := rc.getGithubContext() env["CI"] = "true" env["HOME"] = "/github/home" - env["GITHUB_ENV"] = "/github/workflow/envs.txt" + env["GITHUB_ENV"] = "/github/workflow/envs.txt" env["GITHUB_WORKFLOW"] = github.Workflow env["GITHUB_RUN_ID"] = github.RunID env["GITHUB_RUN_NUMBER"] = github.RunNumber @@ -594,6 +594,18 @@ func (rc *RunContext) withGithubEnv(env map[string]string) map[string]string { env["GITHUB_SERVER_URL"] = "https://github.com" env["GITHUB_API_URL"] = "https://api.github.com" env["GITHUB_GRAPHQL_URL"] = "https://api.github.com/graphql" + + job := rc.Run.Job() + if job.RunsOn() != nil { + for _, runnerLabel := range job.RunsOn() { + platformName := rc.ExprEval.Interpolate(runnerLabel) + if platformName != "" { + platformName = strings.SplitN(strings.Replace(platformName, `-`, ``, 1), `.`, 1)[0] + env["ImageOS"] = platformName + } + } + } + return env }