1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

Add support for step.working-directory (closes #149) (#154)

This commit is contained in:
Aidan Steele 2020-03-14 18:00:37 +11:00 committed by GitHub
parent 41dabfd633
commit 1a3ec6c470
4 changed files with 24 additions and 0 deletions

View file

@ -53,6 +53,7 @@ func TestRunEvent(t *testing.T) {
{"local-action-dockerfile", "push", ""}, {"local-action-dockerfile", "push", ""},
{"matrix", "push", ""}, {"matrix", "push", ""},
{"commands", "push", ""}, {"commands", "push", ""},
{"workdir", "push", ""},
} }
log.SetLevel(log.DebugLevel) log.SetLevel(log.DebugLevel)

View file

@ -110,6 +110,13 @@ func (sc *StepContext) setupShellCommand() common.Executor {
return err 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) run := rc.ExprEval.Interpolate(step.Run)
if _, err = script.WriteString(run); err != nil { if _, err = script.WriteString(run); err != nil {

0
act/runner/testdata/workdir/canary vendored Normal file
View file

16
act/runner/testdata/workdir/push.yml vendored Normal file
View file

@ -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" ]]'