Repository: nektos/act (language: go)

Issue:
PATH is overwritten
### Bug report info

```plain text
act version:            0.2.34-18-g4989f44
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 12
Docker host:            DOCKER_HOST environment variable is unset/empty.
Sockets found:
	/var/run/docker.sock
Config files:           
	/home/markusw/.actrc:
		-P ubuntu-latest=node:12-buster-slim
		-P ubuntu-20.04=node:12-buster-slim
		-P ubuntu-18.04=node:12-buster-slim
		-P ubuntu-16.04=node:12-stretch-slim
Build info:
	Go version:            go1.19.4
	Module path:           command-line-arguments
	Main version:          
	Main path:             
	Main checksum:         
	Build settings:
		-compiler:            gc
		-ldflags:             -X main.version=0.2.34-18-g4989f44
		CGO_ENABLED:          1
		CGO_CFLAGS:           
		CGO_CPPFLAGS:         
		CGO_CXXFLAGS:         
		CGO_LDFLAGS:          
		GOARCH:               amd64
		GOOS:                 linux
		GOAMD64:              v1
Docker Engine:
	Engine version:        20.10.21+dfsg1
	Engine runtime:        runc
	Cgroup version:        2
	Cgroup driver:         systemd
	Storage driver:        overlay2
	Registry URI:          https://index.docker.io/v1/
	OS:                    Debian GNU/Linux bookworm/sid
	OS type:               linux
	OS version:            
	OS arch:               x86_64
	OS kernel:             6.0.0-5-amd64
	OS CPU:                12
	OS memory:             31734 MB
	Security options:
		name=apparmor
		name=seccomp,profile=default
		name=cgroupns
```


### Command used with act

```sh
act
```


### Describe issue

The PATH variable is overwritten (or reset) when an action is executed wich creates some output.
The workflow below prints the PATH in two places:

1. after `actions/setup-node` and the node bins are in the PATH
2. after the `fea/changelog-action`. In that place the PATH was reset.

The changelog actions is private, but in essence it just defines an output string. It does not install tools or modifies the PATH.


### Link to GitHub repository

_No response_

### Workflow content

```yml
name: test
on: push
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v3
        with:
          node-version: 18
      - name: debug 0
        run: |
          echo PATH=$PATH
      - id: changelog
        uses: fea/changelog-action@v1
      - name: debug 1
        run: |
          echo PATH=$PATH
```


### Relevant log output

```sh
[test/test] ⭐ Run Pre fea/changelog-action@v1
[test/test]   ✅  Success - Pre fea/changelog-action@v1
[test/test] ⭐ Run Main actions/setup-node@v3
[test/test]   🐳  docker cp src=/home/markusw/.cache/act/actions-setup-node@v3/ dst=/var/run/act/actions/actions-setup-node@v3/
[test/test]   🐳  docker exec cmd=[node /var/run/act/actions/actions-setup-node@v3/dist/setup/index.js] user= workdir=
[test/test]   💬  ::debug::isExplicit: 
[test/test]   💬  ::debug::explicit? false
[test/test]   💬  ::debug::evaluating 0 versions
[test/test]   💬  ::debug::match not found
| Attempting to download 18...
[test/test]   💬  ::debug::No manifest cached
[test/test]   💬  ::debug::Getting manifest from actions/node-versions@main
[test/test]   💬  ::debug::check 18.12.1 satisfies 18
[test/test]   💬  ::debug::x64===x64 && darwin===linux
[test/test]   💬  ::debug::x64===x64 && linux===linux
[test/test]   💬  ::debug::matched 18.12.1
| Acquiring 18.12.1 - x64 from https://github.com/actions/node-versions/releases/download/18.12.1-3486235546/node-18.12.1-linux-x64.tar.gz
[test/test]   💬  ::debug::Downloading https://github.com/actions/node-versions/releases/download/18.12.1-3486235546/node-18.12.1-linux-x64.tar.gz
[test/test]   💬  ::debug::Destination /tmp/13b3dc68-7093-4428-bcee-91a6101f7fc9
[test/test]   💬  ::debug::download complete
| Extracting ...
[test/test]   💬  ::debug::Checking tar --version
[test/test]   💬  ::debug::tar (GNU tar) 1.30%0ACopyright (C) 2017 Free Software Foundation, Inc.%0ALicense GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.%0AThis is free software: you are free to change and redistribute it.%0AThere is NO WARRANTY, to the extent permitted by law.%0A%0AWritten by John Gilmore and Jay Fenlason.
| [command]/usr/bin/tar xz --strip 1 --warning=no-unknown-keyword -C /tmp/581a5375-8560-427c-a875-2cb808147a53 -f /tmp/13b3dc68-7093-4428-bcee-91a6101f7fc9
| Adding to the cache ...
[test/test]   💬  ::debug::Caching tool node 18.12.1 x64
[test/test]   💬  ::debug::source dir: /tmp/581a5375-8560-427c-a875-2cb808147a53
[test/test]   💬  ::debug::destination /opt/hostedtoolcache/node/18.12.1/x64
[test/test]   💬  ::debug::finished caching tool
| Done
[test/test]   ❓  ::group::Environment details
| node: v18.12.1
| 
| yarn: 1.22.19
| 
| npm: 8.19.2
| 
[test/test]   ❓  ::endgroup::
[test/test]   ❓  ##[add-matcher]/run/act/actions/actions-setup-node@v3/.github/tsc.json
[test/test]   ❓  ##[add-matcher]/run/act/actions/actions-setup-node@v3/.github/eslint-stylish.json
[test/test]   ❓  ##[add-matcher]/run/act/actions/actions-setup-node@v3/.github/eslint-compact.json
[test/test]   ✅  Success - Main actions/setup-node@v3
[test/test]   ⚙  ::set-output:: node-version=v18.12.1
[test/test]   ⚙  ::add-path:: /opt/hostedtoolcache/node/18.12.1/x64/bin
[test/test] ⭐ Run Main debug 0
[test/test]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1] user= workdir=
| PATH=/opt/hostedtoolcache/node/18.12.1/x64/bin:"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin":/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[test/test]   ✅  Success - Main debug 0
[test/test] ⭐ Run Main fea/changelog-action@v1
[test/test]   🐳  docker cp src=/home/markusw/.cache/act/fea-changelog-action@v1/ dst=/var/run/act/actions/fea-changelog-action@v1/
[test/test] ⭐ Run Main Create changelog
[test/test]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/changelog-composite-generate.sh] user= workdir=
| fatal: not a git repository (or any parent up to mount point /home/markusw/source/xxx/source)
| Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
| Processing commits
| fatal: not a git repository (or any parent up to mount point /home/markusw/source/xxx/source)
| Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
[test/test]   ❓  ::group::Changelog
| 
[test/test]   ❓  ::endgroup::
[test/test]   ⚙  ::set-output:: content=
[test/test]   ✅  Success - Main Create changelog
[test/test]   ⚙  ::set-output:: content=
[test/test]   ✅  Success - Main fea/changelog-action@v1
[test/test] ⭐ Run Main debug 1
[test/test]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/3] user= workdir=
| PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin":/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[test/test]   ✅  Success - Main debug 1
[test/test] ⭐ Run Post fea/changelog-action@v1
[test/test]   🐳  docker cp src=/home/markusw/.cache/act/fea-changelog-action@v1/ dst=/var/run/act/actions/fea-changelog-action@v1/
[test/test]   ✅  Success - Post fea/changelog-action@v1
[test/test] ⭐ Run Post actions/setup-node@v3
[test/test]   🐳  docker exec cmd=[node /var/run/act/actions/actions-setup-node@v3/dist/cache-save/index.js] user= workdir=
[test/test]   💬  ::debug::Caching for '' is not supported
[test/test]   ✅  Success - Post actions/setup-node@v3
[test/test] 🏁  Job succeeded
```


### Additional information

_No response_


Discussion / hints:

Fix patch:
diff --git a/pkg/runner/step_action_remote.go b/pkg/runner/step_action_remote.go
index 00d9502a3e4..178348663fe 100644
--- a/pkg/runner/step_action_remote.go
+++ b/pkg/runner/step_action_remote.go
@@ -196,6 +196,7 @@ func (sar *stepActionRemote) getCompositeRunContext(ctx context.Context) *RunCon
 		// was already created during the pre stage)
 		env := evaluateCompositeInputAndEnv(ctx, sar.RunContext, sar)
 		sar.compositeRunContext.Env = env
+		sar.compositeRunContext.ExtraPath = sar.RunContext.ExtraPath
 	}
 	return sar.compositeRunContext
 }


Test patch:
diff --git a/pkg/runner/runner_test.go b/pkg/runner/runner_test.go
index ceae70c5af5..95fbbcc2175 100644
--- a/pkg/runner/runner_test.go
+++ b/pkg/runner/runner_test.go
@@ -201,6 +201,7 @@ func TestRunEvent(t *testing.T) {
 		{"../model/testdata", "strategy", "push", "", platforms, secrets}, // TODO: move all testdata into pkg so we can validate it with planner and runner
 		// {"testdata", "issue-228", "push", "", platforms, }, // TODO [igni]: Remove this once everything passes
 		{"../model/testdata", "container-volumes", "push", "", platforms, secrets},
+		{workdir, "path-handling", "push", "", platforms, secrets},
 	}
 
 	for _, table := range tables {
diff --git a/pkg/runner/testdata/path-handling/action.yml b/pkg/runner/testdata/path-handling/action.yml
new file mode 100644
index 00000000000..8db98c52abe
--- /dev/null
+++ b/pkg/runner/testdata/path-handling/action.yml
@@ -0,0 +1,21 @@
+name: output action
+description: output action
+
+inputs:
+  input:
+    description: some input
+    required: false
+
+outputs:
+  job-output:
+    description: some output
+    value: ${{ steps.gen-out.outputs.step-output }}
+
+runs:
+  using: composite
+  steps:
+    - name: run step
+      id: gen-out
+      run: |
+        echo "::set-output name=step-output::"
+      shell: bash
diff --git a/pkg/runner/testdata/path-handling/push.yml b/pkg/runner/testdata/path-handling/push.yml
new file mode 100644
index 00000000000..812c8b8a289
--- /dev/null
+++ b/pkg/runner/testdata/path-handling/push.yml
@@ -0,0 +1,39 @@
+name: path tests
+on: push
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+
+      - name: "Append to $GITHUB_PATH"
+        run: |
+          echo "/opt/hostedtoolcache/node/18.99/x64/bin" >> $GITHUB_PATH
+ 
+      - name: test path (after setup)
+        run: |
+          if ! echo "$PATH" |grep "/opt/hostedtoolcache/node/18.*/\(x64\|arm64\)/bin" ; then
+            echo "Node binaries not in path: $PATH"
+            exit 1
+          fi
+
+      - id: action-with-output
+        uses: ./path-handling/
+
+      - name: test path (after local action)
+        run: |
+          if ! echo "$PATH" |grep "/opt/hostedtoolcache/node/18.*/\(x64\|arm64\)/bin" ; then
+            echo "Node binaries not in path: $PATH"
+            exit 1
+          fi
+
+      - uses: nektos/act-test-actions/composite@main
+        with:
+          input: some input
+
+      - name: test path (after remote action)
+        run: |
+          if ! echo "$PATH" |grep "/opt/hostedtoolcache/node/18.*/\(x64\|arm64\)/bin" ; then
+            echo "Node binaries not in path: $PATH"
+            exit 1
+          fi