Repository: nektos/act (language: go)

Issue:
Add support for '${{ inputs.xyz }}' when using the workflow_call event.
### Bug report info

```plain text
act version:            0.2.35
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 8
Docker host:            DOCKER_HOST environment variable is unset/empty.
Sockets found:
	/var/run/docker.sock
Config files:           
	/home/maurits/.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.18.9
	Module path:           github.com/nektos/act
	Main version:          (devel)
	Main path:             github.com/nektos/act
	Main checksum:         
	Build settings:
		-compiler:            gc
		-ldflags:             -s -w -X main.version=0.2.35 -X main.commit=e3a722e7c6c697a1b0a38aa314bfb227da4deb5f -X main.date=2023-01-01T02:32:00Z -X main.builtBy=goreleaser
		CGO_ENABLED:          0
		GOARCH:               amd64
		GOOS:                 linux
		GOAMD64:              v1
		vcs:                  git
		vcs.revision:         e3a722e7c6c697a1b0a38aa314bfb227da4deb5f
		vcs.time:             2022-12-26T02:28:46Z
		vcs.modified:         false
Docker Engine:
	Engine version:        20.10.21
	Engine runtime:        runc
	Cgroup version:        1
	Cgroup driver:         cgroupfs
	Storage driver:        overlay2
	Registry URI:          https://index.docker.io/v1/
	OS:                    Linux Mint 20.3
	OS type:               linux
	OS version:            20.3
	OS arch:               x86_64
	OS kernel:             5.4.0-131-generic
	OS CPU:                8
	OS memory:             31941 MB
	Security options:
		name=apparmor
		name=seccomp,profile=default
```


### Command used with act

```sh
act workflow_call --eventpath event.json
```


### Describe issue

When using workflow_call the `inputs` variable is empty.
This functionality does work when using the workflow_dispatch event type.

Apparently the reason that things work for workflow_dispatch is due to this PR: https://github.com/nektos/act/pull/1363

I am aware that full support for reusable workflows isn't available.
However, it would be really useful if we can at least call individual workflows using the workflow_call event, in order to make the testing of individual workflows possible. The behavior added in the PR can probably be replicated for this event type.

### Link to GitHub repository

_No response_

### Workflow content

```yml
name: "project"
on:
  workflow_call:
    inputs:
      dummy:
        type: string
  workflow_dispatch:
    inputs:
      dummy:
        type: string
jobs:
  test_inputs:
    name: input test
    runs-on: ubuntu-latest
    steps:
      - run: echo "INPUT = ${{ inputs.dummy }}"
```


### Relevant log output

```sh
$ act workflow_call --eventpath event.json
[project/input test] 🚀  Start image=catthehacker/ubuntu:act-latest
[project/input test]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=false
[project/input test]   🐳  docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[project/input test]   🐳  docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[project/input test] ⭐ Run Main echo "INPUT = "
[project/input test]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
| INPUT = 
[project/input test]   ✅  Success - Main echo "INPUT = "
[project/input test] 🏁  Job succeeded
$ act workflow_dispatch --eventpath event.json
[project/input test] 🚀  Start image=catthehacker/ubuntu:act-latest
[project/input test]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=false
[project/input test]   🐳  docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[project/input test]   🐳  docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[project/input test] ⭐ Run Main echo "INPUT = Hello!"
[project/input test]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
| INPUT = Hello!
[project/input test]   ✅  Success - Main echo "INPUT = Hello!"
[project/input test] 🏁  Job succeeded
```


### Additional information

Event JSON file:

`{
  "inputs": {
    "dummy": "Hello!"
  }
}`


Discussion / hints:
The --input is not working on my end as well.

Step to reproduce:
1. `git clone https://github.com/EugenioTesio/hello-world-dart-action.git`
2. `act -j hello_world_job --input who-to-greet=Eugenio --container-architecture linux/arm64`

If you are running on a non M1 chipset machine, you can get rid of `--container-architecture linux/arm64`

Current output:

```bash
[main.yml/A job to say hello] 🚀  Start image=catthehacker/ubuntu:act-latest
[main.yml/A job to say hello]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform=linux/arm64 username= forcePull=false
[main.yml/A job to say hello]   🐳  docker create image=catthehacker/ubuntu:act-latest platform=linux/arm64 entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[main.yml/A job to say hello]   🐳  docker run image=catthehacker/ubuntu:act-latest platform=linux/arm64 entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[main.yml/A job to say hello] ⭐ Run Main Checkout
[main.yml/A job to say hello]   🐳  docker cp src=/Users/eugeniotesio/development/themonkslab/hello-world-dart-action/. dst=/Users/eugeniotesio/development/themonkslab/hello-world-dart-action
[main.yml/A job to say hello]   ✅  Success - Main Checkout
[main.yml/A job to say hello] ⭐ Run Main Hello world action step
[main.yml/A job to say hello]   🐳  docker pull image=act-dockeraction:latest platform=linux/arm64 username= forcePull=false
[main.yml/A job to say hello]   🐳  docker create image=act-dockeraction:latest platform=linux/arm64 entrypoint=[] cmd=["Mona the Octocat"]
[main.yml/A job to say hello]   🐳  docker run image=act-dockeraction:latest platform=linux/arm64 entrypoint=[] cmd=["Mona the Octocat"]
| Hello Mona the Octocat
| 
[main.yml/A job to say hello]   ⚙  ::set-output:: time=2023-01-25 12:22:06.652950
[main.yml/A job to say hello]   ✅  Success - Main Hello world action step
[main.yml/A job to say hello] ⭐ Run Main Get the output time
[main.yml/A job to say hello]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/2] user= workdir=
| The time was 2023-01-25 12:22:06.652950
[main.yml/A job to say hello]   ✅  Success - Main Get the output time
[main.yml/A job to say hello] 🏁  Job succeeded
```

I should get Hello Eugenio instead of Mona the Octocat.
Can confirm on linux/x64

Merely changing workflow_call -> workflow_dispatch for testing allows the workflow to continue as expected
Ran into this and would pick this up if no one else is working on it.

Fix patch:
diff --git a/pkg/runner/expression.go b/pkg/runner/expression.go
index cc144afe481..24b16f88b18 100644
--- a/pkg/runner/expression.go
+++ b/pkg/runner/expression.go
@@ -397,6 +397,7 @@ func rewriteSubExpression(ctx context.Context, in string, forceFormat bool) (str
 	return out, nil
 }
 
+//nolint:gocyclo
 func getEvaluatorInputs(ctx context.Context, rc *RunContext, step step, ghc *model.GithubContext) map[string]interface{} {
 	inputs := map[string]interface{}{}
 
@@ -432,6 +433,22 @@ func getEvaluatorInputs(ctx context.Context, rc *RunContext, step step, ghc *mod
 		}
 	}
 
+	if ghc.EventName == "workflow_call" {
+		config := rc.Run.Workflow.WorkflowCallConfig()
+		if config != nil && config.Inputs != nil {
+			for k, v := range config.Inputs {
+				value := nestedMapLookup(ghc.Event, "inputs", k)
+				if value == nil {
+					value = v.Default
+				}
+				if v.Type == "boolean" {
+					inputs[k] = value == "true"
+				} else {
+					inputs[k] = value
+				}
+			}
+		}
+	}
 	return inputs
 }
 


Test patch:
diff --git a/pkg/runner/runner_test.go b/pkg/runner/runner_test.go
index db63fb94b27..5b8257c3358 100644
--- a/pkg/runner/runner_test.go
+++ b/pkg/runner/runner_test.go
@@ -288,6 +288,7 @@ func TestRunEvent(t *testing.T) {
 		{workdir, "docker-action-custom-path", "push", "", platforms, secrets},
 		{workdir, "GITHUB_ENV-use-in-env-ctx", "push", "", platforms, secrets},
 		{workdir, "ensure-post-steps", "push", "Job 'second-post-step-should-fail' failed", platforms, secrets},
+		{workdir, "workflow_call_inputs", "workflow_call", "", platforms, secrets},
 		{workdir, "workflow_dispatch", "workflow_dispatch", "", platforms, secrets},
 		{workdir, "workflow_dispatch_no_inputs_mapping", "workflow_dispatch", "", platforms, secrets},
 		{workdir, "workflow_dispatch-scalar", "workflow_dispatch", "", platforms, secrets},
diff --git a/pkg/runner/testdata/workflow_call_inputs/event.json b/pkg/runner/testdata/workflow_call_inputs/event.json
new file mode 100644
index 00000000000..d3ecab10e1b
--- /dev/null
+++ b/pkg/runner/testdata/workflow_call_inputs/event.json
@@ -0,0 +1,6 @@
+{
+  "inputs": {
+    "required": "required input",
+    "boolean": "true"
+  }
+}
diff --git a/pkg/runner/testdata/workflow_call_inputs/workflow_call_inputs.yml b/pkg/runner/testdata/workflow_call_inputs/workflow_call_inputs.yml
new file mode 100644
index 00000000000..1a5cca3f735
--- /dev/null
+++ b/pkg/runner/testdata/workflow_call_inputs/workflow_call_inputs.yml
@@ -0,0 +1,36 @@
+name: workflow_call
+
+on:
+  workflow_call:
+    inputs:
+      required:
+        description: a required input
+        required: true
+      with_default:
+        description: an input with default
+        required: false
+        default: default
+      boolean:
+        description: an input of type boolean
+        required: false
+        type: boolean
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    steps:
+      - name: test required input
+        run: |
+          echo input.required=${{ inputs.required }}
+          [[ "${{ inputs.required }}" = "required input" ]] || exit 1
+      - name: test input with default
+        run: |
+          echo input.with_default=${{ inputs.with_default }}
+          [[ "${{ inputs.with_default }}" = "default" ]] || exit 1
+      - id: boolean-test
+        name: run on boolean input
+        if: ${{ inputs.boolean == true }}
+        run: echo "::set-output name=value::executed"
+      - name: has boolean test?
+        run: |
+          [[ "${{ steps.boolean-test.outputs.value }}" = "executed" ]] || exit 1