fix: add ImageOS env var based on running platform (#571)

This commit is contained in:
hackercat 2021-03-18 01:14:08 +01:00 committed by GitHub
parent 09679f0156
commit 41b03b581c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}