fix: align runner.os / runner.arch to known values (#1510)
* fix: align runner.os / runner.arch to known values * . * . Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
bef9b5c3c7
commit
6ab71ecebb
2 changed files with 29 additions and 6 deletions
|
@ -410,10 +410,32 @@ func (*HostEnvironment) JoinPathVariable(paths ...string) string {
|
||||||
return strings.Join(paths, string(filepath.ListSeparator))
|
return strings.Join(paths, string(filepath.ListSeparator))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func goArchToActionArch(arch string) string {
|
||||||
|
archMapper := map[string]string{
|
||||||
|
"x86_64": "X64",
|
||||||
|
"386": "x86",
|
||||||
|
"aarch64": "arm64",
|
||||||
|
}
|
||||||
|
if arch, ok := archMapper[arch]; ok {
|
||||||
|
return arch
|
||||||
|
}
|
||||||
|
return arch
|
||||||
|
}
|
||||||
|
|
||||||
|
func goOsToActionOs(os string) string {
|
||||||
|
osMapper := map[string]string{
|
||||||
|
"darwin": "macOS",
|
||||||
|
}
|
||||||
|
if os, ok := osMapper[os]; ok {
|
||||||
|
return os
|
||||||
|
}
|
||||||
|
return os
|
||||||
|
}
|
||||||
|
|
||||||
func (e *HostEnvironment) GetRunnerContext(ctx context.Context) map[string]interface{} {
|
func (e *HostEnvironment) GetRunnerContext(ctx context.Context) map[string]interface{} {
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
"os": runtime.GOOS,
|
"os": goOsToActionOs(runtime.GOOS),
|
||||||
"arch": runtime.GOARCH,
|
"arch": goArchToActionArch(runtime.GOARCH),
|
||||||
"temp": e.TmpDir,
|
"temp": e.TmpDir,
|
||||||
"tool_cache": e.ToolCache,
|
"tool_cache": e.ToolCache,
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,10 +179,11 @@ func (rc *RunContext) startHostEnvironment() common.Executor {
|
||||||
StdOut: logWriter,
|
StdOut: logWriter,
|
||||||
}
|
}
|
||||||
rc.cleanUpJobContainer = rc.JobContainer.Remove()
|
rc.cleanUpJobContainer = rc.JobContainer.Remove()
|
||||||
rc.Env["RUNNER_TOOL_CACHE"] = toolCache
|
for k, v := range rc.JobContainer.GetRunnerContext(ctx) {
|
||||||
rc.Env["RUNNER_OS"] = runtime.GOOS
|
if v, ok := v.(string); ok {
|
||||||
rc.Env["RUNNER_ARCH"] = runtime.GOARCH
|
rc.Env[fmt.Sprintf("RUNNER_%s", strings.ToUpper(k))] = v
|
||||||
rc.Env["RUNNER_TEMP"] = runnerTmp
|
}
|
||||||
|
}
|
||||||
for _, env := range os.Environ() {
|
for _, env := range os.Environ() {
|
||||||
i := strings.Index(env, "=")
|
i := strings.Index(env, "=")
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
|
|
Loading…
Reference in a new issue