File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,18 @@ function checkInputs() {
1313 const eventPath = process . env . GITHUB_EVENT_PATH
1414 if ( eventPath ) {
1515 const { author } = require ( eventPath ) . head_commit
16- if ( ! process . env . INPUT_AUTHOR_NAME ) process . env . INPUT_AUTHOR_NAME = author . name
17- if ( ! process . env . INPUT_AUTHOR_EMAIL ) process . env . INPUT_AUTHOR_EMAIL = author . email
16+ setDefault ( 'author_name' , author . name )
17+ setDefault ( 'author_email' , author . email )
1818 } else {
1919 core . warning ( 'No event path available, unable to fetch author info.' )
20- if ( ! process . env . INPUT_AUTHOR_NAME ) process . env . INPUT_AUTHOR_NAME = 'Add & Commit Action'
21- if ( ! process . env . INPUT_AUTHOR_EMAIL ) process . env . INPUT_AUTHOR_EMAIL = 'actions@github.com'
20+ setDefault ( 'author_name' , 'Add & Commit Action' )
21+ setDefault ( 'author_email' , 'actions@github.com' )
2222 }
23+ core . info ( `Using '${ core . getInput ( 'author_name' ) } <${ core . getInput ( 'author_email' ) } >' as author.` )
2324 core . info ( `Using '${ process . env . INPUT_AUTHOR_NAME } <${ process . env . INPUT_AUTHOR_EMAIL } >' as author.` )
2425}
26+
27+ function setDefault ( input : string , value : string ) {
28+ const key = 'INPUT_' + input . toUpperCase ( )
29+ if ( ! process . env [ key ] ) process . env [ key ] = value
30+ }
You can’t perform that action at this time.
0 commit comments