diff --git a/act/runner/runner_test.go b/act/runner/runner_test.go index 9e6ee912..8b9e1be1 100644 --- a/act/runner/runner_test.go +++ b/act/runner/runner_test.go @@ -53,6 +53,7 @@ func TestRunEvent(t *testing.T) { {"local-action-dockerfile", "push", ""}, {"matrix", "push", ""}, {"commands", "push", ""}, + {"workdir", "push", ""}, } log.SetLevel(log.DebugLevel) diff --git a/act/runner/step_context.go b/act/runner/step_context.go index 379a14a4..7c30c67c 100644 --- a/act/runner/step_context.go +++ b/act/runner/step_context.go @@ -110,6 +110,13 @@ func (sc *StepContext) setupShellCommand() common.Executor { return err } + if step.WorkingDirectory != "" { + _, err = script.WriteString(fmt.Sprintf("cd %s\n", step.WorkingDirectory)) + if err != nil { + return err + } + } + run := rc.ExprEval.Interpolate(step.Run) if _, err = script.WriteString(run); err != nil { diff --git a/act/runner/testdata/workdir/canary b/act/runner/testdata/workdir/canary new file mode 100644 index 00000000..e69de29b diff --git a/act/runner/testdata/workdir/push.yml b/act/runner/testdata/workdir/push.yml new file mode 100644 index 00000000..16c7fe4b --- /dev/null +++ b/act/runner/testdata/workdir/push.yml @@ -0,0 +1,16 @@ +name: workdir +on: push + +jobs: + workdir: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: '[[ "$(pwd)" == "/github/workspace/workdir" ]]' + working-directory: workdir + + noworkdir: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: '[[ "$(pwd)" == "/github/workspace" ]]'