@@ -58,12 +58,21 @@ public override void PrintActionDetails(ActionRunStage stage)
5858 string shellCommandPath = null ;
5959 bool validateShellOnHost = ! ( StepHost is ContainerStepHost ) ;
6060 string prependPath = string . Join ( Path . PathSeparator . ToString ( ) , ExecutionContext . PrependPath . Reverse < string > ( ) ) ;
61- Inputs . TryGetValue ( "shell" , out var shell ) ;
61+ string shell = null ;
62+ if ( ! Inputs . TryGetValue ( "shell" , out shell ) || string . IsNullOrEmpty ( shell ) )
63+ {
64+ // TODO: figure out how defaults interact with template later
65+ // for now, we won't check job.defaults if we are inside a template.
66+ if ( string . IsNullOrEmpty ( ExecutionContext . ScopeName ) && ExecutionContext . JobDefaults . TryGetValue ( "run" , out var runDefaults ) )
67+ {
68+ runDefaults . TryGetValue ( "shell" , out shell ) ;
69+ }
70+ }
6271 if ( string . IsNullOrEmpty ( shell ) )
6372 {
6473#if OS_WINDOWS
6574 shellCommand = "pwsh" ;
66- if ( validateShellOnHost )
75+ if ( validateShellOnHost )
6776 {
6877 shellCommandPath = WhichUtil . Which ( shellCommand , require : false , Trace , prependPath ) ;
6978 if ( string . IsNullOrEmpty ( shellCommandPath ) )
@@ -139,11 +148,36 @@ public async Task RunAsync(ActionRunStage stage)
139148 Inputs . TryGetValue ( "script" , out var contents ) ;
140149 contents = contents ?? string . Empty ;
141150
142- Inputs . TryGetValue ( "workingDirectory" , out var workingDirectory ) ;
151+ string workingDirectory = null ;
152+ if ( ! Inputs . TryGetValue ( "workingDirectory" , out workingDirectory ) )
153+ {
154+ // TODO: figure out how defaults interact with template later
155+ // for now, we won't check job.defaults if we are inside a template.
156+ if ( string . IsNullOrEmpty ( ExecutionContext . ScopeName ) && ExecutionContext . JobDefaults . TryGetValue ( "run" , out var runDefaults ) )
157+ {
158+ if ( runDefaults . TryGetValue ( "working-directory" , out workingDirectory ) )
159+ {
160+ ExecutionContext . Debug ( "Overwrite 'working-directory' base on job defaults." ) ;
161+ }
162+ }
163+ }
143164 var workspaceDir = githubContext [ "workspace" ] as StringContextData ;
144165 workingDirectory = Path . Combine ( workspaceDir , workingDirectory ?? string . Empty ) ;
145166
146- Inputs . TryGetValue ( "shell" , out var shell ) ;
167+ string shell = null ;
168+ if ( ! Inputs . TryGetValue ( "shell" , out shell ) || string . IsNullOrEmpty ( shell ) )
169+ {
170+ // TODO: figure out how defaults interact with template later
171+ // for now, we won't check job.defaults if we are inside a template.
172+ if ( string . IsNullOrEmpty ( ExecutionContext . ScopeName ) && ExecutionContext . JobDefaults . TryGetValue ( "run" , out var runDefaults ) )
173+ {
174+ if ( runDefaults . TryGetValue ( "shell" , out shell ) )
175+ {
176+ ExecutionContext . Debug ( "Overwrite 'shell' base on job defaults." ) ;
177+ }
178+ }
179+ }
180+
147181 var isContainerStepHost = StepHost is ContainerStepHost ;
148182
149183 string prependPath = string . Join ( Path . PathSeparator . ToString ( ) , ExecutionContext . PrependPath . Reverse < string > ( ) ) ;
0 commit comments