We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f75a2d8 commit 3a9d402Copy full SHA for 3a9d402
pkg/model/workflow.go
@@ -572,6 +572,8 @@ type Step struct {
572
Uses string `yaml:"uses"`
573
Run string `yaml:"run"`
574
WorkingDirectory string `yaml:"working-directory"`
575
+ // WorkflowShell is the shell really configured in the job, directly at step level or higher in defaults.run.shell
576
+ WorkflowShell string
577
Shell string `yaml:"shell"`
578
Env yaml.Node `yaml:"env"`
579
With map[string]string `yaml:"with"`
@@ -614,8 +616,14 @@ func (s *Step) ShellCommand() string {
614
616
615
617
//Reference: https://github.com/actions/runner/blob/8109c962f09d9acc473d92c595ff43afceddb347/src/Runner.Worker/Handlers/ScriptHandlerHelpers.cs#L9-L17
618
switch s.Shell {
- case "", "bash":
- shellCommand = "bash --noprofile --norc -e -o pipefail {0}"
619
+ case "":
620
+ shellCommand = "bash -e {0}"
621
+ case "bash":
622
+ if s.WorkflowShell == "" {
623
624
+ } else {
625
+ shellCommand = "bash --noprofile --norc -e -o pipefail {0}"
626
+ }
627
case "pwsh":
628
shellCommand = "pwsh -command . '{0}'"
629
case "python":
pkg/model/workflow_test.go
@@ -397,15 +397,18 @@ func TestReadWorkflow_Strategy(t *testing.T) {
397
func TestStep_ShellCommand(t *testing.T) {
398
tests := []struct {
399
shell string
400
+ workflowShell string
401
want string
402
}{
- {"pwsh -v '. {0}'", "pwsh -v '. {0}'"},
403
- {"pwsh", "pwsh -command . '{0}'"},
404
- {"powershell", "powershell -command . '{0}'"},
+ {"pwsh -v '. {0}'", "", "pwsh -v '. {0}'"},
+ {"pwsh", "", "pwsh -command . '{0}'"},
405
+ {"powershell", "", "powershell -command . '{0}'"},
406
+ {"bash", "", "bash -e {0}"},
407
+ {"bash", "bash", "bash --noprofile --norc -e -o pipefail {0}"},
408
}
409
for _, tt := range tests {
410
t.Run(tt.shell, func(t *testing.T) {
- got := (&Step{Shell: tt.shell}).ShellCommand()
411
+ got := (&Step{Shell: tt.shell, WorkflowShell: tt.workflowShell}).ShellCommand()
412
assert.Equal(t, got, tt.want)
413
})
414
pkg/runner/step_run.go
@@ -166,16 +166,16 @@ func (sr *stepRun) setupShell(ctx context.Context) {
166
step := sr.Step
167
168
if step.Shell == "" {
169
- step.Shell = rc.Run.Job().Defaults.Run.Shell
+ step.WorkflowShell = rc.Run.Job().Defaults.Run.Shell
170
171
172
- step.Shell = rc.NewExpressionEvaluator(ctx).Interpolate(ctx, step.Shell)
+ step.WorkflowShell = rc.NewExpressionEvaluator(ctx).Interpolate(ctx, step.Shell)
173
174
- if step.Shell == "" {
175
- step.Shell = rc.Run.Workflow.Defaults.Run.Shell
+ if step.WorkflowShell == "" {
+ step.WorkflowShell = rc.Run.Workflow.Defaults.Run.Shell
176
177
178
179
if _, ok := rc.JobContainer.(*container.HostEnvironment); ok {
180
shellWithFallback := []string{"bash", "sh"}
181
// Don't use bash on windows by default, if not using a docker container
@@ -196,6 +196,8 @@ func (sr *stepRun) setupShell(ctx context.Context) {
196
// Currently only linux containers are supported, use sh by default like actions/runner
197
step.Shell = "sh"
198
199
200
+ step.Shell = step.WorkflowShell
201
202
203
0 commit comments