@@ -200,6 +200,11 @@ export function getInput(name: string, options?: InputOptions): string {
200
200
process . env [ `INPUT_${ name . replace ( / / g, '_' ) } ` ] ||
201
201
''
202
202
203
+ // If the input is not present in the environment variables, it has not been
204
+ // set. In that case, check the default value.
205
+ if ( input === '' && EnvMeta . inputs [ name ] ?. default !== undefined )
206
+ input = EnvMeta . inputs [ name ] . default . toString ( )
207
+
203
208
// Throw an error if the input is required and not supplied
204
209
if ( options && options . required === true && input === '' )
205
210
throw new Error ( `Input required and not supplied: ${ name } ` )
@@ -224,14 +229,22 @@ export function getMultilineInput(
224
229
options ?: InputOptions
225
230
) : string [ ] {
226
231
// Get input by name, split by newline, and filter out empty strings
227
- const input : string [ ] = (
232
+ let input : string [ ] = (
228
233
process . env [ `INPUT_${ name . replace ( / / g, '_' ) . toUpperCase ( ) } ` ] ||
229
234
process . env [ `INPUT_${ name . replace ( / / g, '_' ) } ` ] ||
230
235
''
231
236
)
232
237
. split ( '\n' )
233
238
. filter ( x => x !== '' )
234
239
240
+ // If the input is not present in the environment variables, it has not been
241
+ // set. In that case, check the default value.
242
+ if ( input . length === 0 && EnvMeta . inputs [ name ] ?. default !== undefined )
243
+ input = EnvMeta . inputs [ name ] . default
244
+ . toString ( )
245
+ . split ( '\n' )
246
+ . filter ( x => x !== '' )
247
+
235
248
// Throw an error if the input is required and not supplied
236
249
if ( options && options . required === true && input . length === 0 )
237
250
throw new Error ( `Input required and not supplied: ${ name } ` )
@@ -257,12 +270,17 @@ export function getBooleanInput(name: string, options?: InputOptions): boolean {
257
270
// using proxyquire's `callThru()` option.
258
271
259
272
// Get input by name, or an empty string if not found
260
- const input : string = (
273
+ let input : string = (
261
274
process . env [ `INPUT_${ name . replace ( / / g, '_' ) . toUpperCase ( ) } ` ] ||
262
275
process . env [ `INPUT_${ name . replace ( / / g, '_' ) } ` ] ||
263
276
''
264
277
) . trim ( )
265
278
279
+ // If the input is not present in the environment variables, it has not been
280
+ // set. In that case, check the default value.
281
+ if ( input === '' && EnvMeta . inputs [ name ] ?. default !== undefined )
282
+ input = EnvMeta . inputs [ name ] . default . trim ( )
283
+
266
284
// Throw an error if the input is required and not supplied
267
285
if ( options && options . required === true && input === '' )
268
286
throw new Error ( `Input required and not supplied: ${ name } ` )
0 commit comments