Repository: nektos/act (language: go)

Issue:
RUNNER_OS should return macOS instead of darwin and wrong RUNNER_ARCH on MacOS M1
### Bug report info

```plain text
act --bug-report                                    
act version:            0.2.34
GOOS:                   darwin
GOARCH:                 amd64
NumCPU:                 8
Docker host:            DOCKER_HOST environment variable is unset/empty.
Sockets found:
	/var/run/docker.sock
	/Users/yuriiuvarov/.docker/run/docker.sock
Config files:           
	/Users/yuriiuvarov/.actrc:
		-P ubuntu-latest=catthehacker/ubuntu:act-latest
		-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
		-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
		-P ubuntu-18.04=catthehacker/ubuntu:act-18.04
	.actrc:
		-P ubuntu-latest=catthehacker/ubuntu:act-latest
		-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
		-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
		-P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
	Go version:            go1.19.3
	Module path:           command-line-arguments
	Main version:          
	Main path:             
	Main checksum:         
	Build settings:
		-compiler:            gc
		-ldflags:             -X main.version=0.2.34
		CGO_ENABLED:          1
		CGO_CFLAGS:           
		CGO_CPPFLAGS:         
		CGO_CXXFLAGS:         
		CGO_LDFLAGS:          
		GOARCH:               amd64
		GOOS:                 darwin
		GOAMD64:              v1
Docker Engine:
	Engine version:        20.10.21
	Engine runtime:        runc
	Cgroup version:        2
	Cgroup driver:         cgroupfs
	Storage driver:        overlay2
	Registry URI:          https://index.docker.io/v1/
	OS:                    Docker Desktop
	OS type:               linux
	OS version:            
	OS arch:               aarch64
	OS kernel:             5.15.49-linuxkit
	OS CPU:                4
	OS memory:             3933 MB
	Security options:
		name=seccomp,profile=default
		name=cgroupns
```


### Command used with act

```sh
act -j build --platform macos-latest=-self-hosted
```


### Describe issue

Some Github actions depend on the `RUNNER_OS` and expect one of the defined values according to the https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables.

> The operating system of the runner executing the job. Possible values are `Linux`, `Windows`, or `macOS`

For example,[ flutter-action](https://github.com/subosito/flutter-action) [uses](https://github.com/subosito/flutter-action/blob/dbf1fa04f4d2e52c33185153d06cdb5443aa189d/setup.sh#L12-L14) `RUNNER_OS` to build a link to the flutter binary.

expected result: macOS, 
actual result: darwin

Also, RUNNER_ARCH should be arm64(or x64 using rosetta at least) but it provides amd64, which is definitely wrong.

### Link to GitHub repository

_No response_

### Workflow content

```yml
name: Linter & Tests

on:
  push:
    branches: [ main, redesign-master ]
  pull_request:
    branches: [ main, redesign-master ]

jobs:
  build:
    runs-on: macos-latest
    env:
      REPO_DIR: ${{ github.workspace }}
    steps:
      - uses: actions/checkout@v3
      - name: 'Test os'
        run: echo $RUNNER_OS
      - name: 'Set Flutter 3.3.9'
        uses: subosito/flutter-action@v2
        with:
          architecture: arm64
          flutter-version: 3.3.9
```


### Relevant log output

```sh
This exceeds the GitHub character limit, please find it here:
https://drive.google.com/file/d/1UYD4cZqcdBm2jMyOISvDMpJ6XJ44LGZq/view?usp=sharing
```


### Additional information

```
uname -a
Darwin Yuriis-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101 arm64
```



Discussion / hints:
@x-yurii-uvarov Could you please check if the arm64 version of act https://github.com/nektos/act/releases/download/v0.2.34/act_Darwin_arm64.tar.gz has the correct RUNNER_ARCH ?

You are right, the RUNNER_OS needs a remapping for macOS.

Fix patch:
diff --git a/pkg/container/host_environment.go b/pkg/container/host_environment.go
index 30cd5005251..ff21b0adba2 100644
--- a/pkg/container/host_environment.go
+++ b/pkg/container/host_environment.go
@@ -410,10 +410,32 @@ func (*HostEnvironment) JoinPathVariable(paths ...string) string {
 	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{} {
 	return map[string]interface{}{
-		"os":         runtime.GOOS,
-		"arch":       runtime.GOARCH,
+		"os":         goOsToActionOs(runtime.GOOS),
+		"arch":       goArchToActionArch(runtime.GOARCH),
 		"temp":       e.TmpDir,
 		"tool_cache": e.ToolCache,
 	}
diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go
index 538e75c9205..c9c8ea1d439 100644
--- a/pkg/runner/run_context.go
+++ b/pkg/runner/run_context.go
@@ -179,10 +179,11 @@ func (rc *RunContext) startHostEnvironment() common.Executor {
 			StdOut: logWriter,
 		}
 		rc.cleanUpJobContainer = rc.JobContainer.Remove()
-		rc.Env["RUNNER_TOOL_CACHE"] = toolCache
-		rc.Env["RUNNER_OS"] = runtime.GOOS
-		rc.Env["RUNNER_ARCH"] = runtime.GOARCH
-		rc.Env["RUNNER_TEMP"] = runnerTmp
+		for k, v := range rc.JobContainer.GetRunnerContext(ctx) {
+			if v, ok := v.(string); ok {
+				rc.Env[fmt.Sprintf("RUNNER_%s", strings.ToUpper(k))] = v
+			}
+		}
 		for _, env := range os.Environ() {
 			i := strings.Index(env, "=")
 			if i > 0 {


Test patch: