@@ -227,49 +227,55 @@ async function checkInputs() {
227
227
// #endregion
228
228
229
229
// #region author_name, author_email
230
- let author = event ?. head_commit ?. author
231
- if ( sha && ! author ) {
232
- info (
233
- '> Unable to get commit from workflow event: trying with the GitHub API ...'
234
- )
230
+ if ( getInput ( 'author_name' ) && getInput ( 'author_email' ) ) {
231
+ info ( '> Using author info from inputs...' )
232
+ } else {
233
+ info ( '> Some author info is missing, filling from workflow event...' )
234
+ let author = event ?. head_commit ?. author
235
235
236
- // https://docs.github.com/en/rest/reference/repos#get-a-commit--code-samples
237
- const url = `https://api.github.com/repos/${ process . env . GITHUB_REPOSITORY } /commits/${ sha } ` ,
238
- headers = token
239
- ? {
240
- Authorization : `Bearer ${ token } `
241
- }
242
- : undefined ,
243
- commit = (
244
- await axios . get ( url , { headers } ) . catch ( ( err ) => {
245
- startGroup ( 'Request error:' )
246
- info ( `> Request URL: ${ url } \b${ err } ` )
247
- endGroup ( )
248
- return undefined
249
- } )
250
- ) ?. data
236
+ if ( sha && ! author ) {
237
+ info (
238
+ '> Unable to get commit from workflow event: trying with the GitHub API...'
239
+ )
251
240
252
- author = commit ?. commit ?. author
253
- }
241
+ // https://docs.github.com/en/rest/reference/repos#get-a-commit--code-samples
242
+ const url = `https://api.github.com/repos/${ process . env . GITHUB_REPOSITORY } /commits/${ sha } ` ,
243
+ headers = token
244
+ ? {
245
+ Authorization : `Bearer ${ token } `
246
+ }
247
+ : undefined ,
248
+ commit = (
249
+ await axios . get ( url , { headers } ) . catch ( ( err ) => {
250
+ startGroup ( 'Request error:' )
251
+ info ( `> Request URL: ${ url } \b${ err } ` )
252
+ endGroup ( )
253
+ return undefined
254
+ } )
255
+ ) ?. data
254
256
255
- if ( author ) {
256
- setDefault ( 'author_name' , author . name )
257
- setDefault ( 'author_email' , author . email )
258
- }
257
+ author = commit ?. commit ?. author
258
+ }
259
259
260
- if ( ! getInput ( 'author_name' ) || ! getInput ( 'author_email' ) ) {
261
- const reason = ! eventPath
262
- ? 'event path'
263
- : isPR
264
- ? sha
265
- ? 'fetch commit'
266
- : 'find commit sha'
267
- : ! event ?. head_commit
268
- ? 'find commit'
269
- : 'find commit author'
270
- warning ( `Unable to fetch author info: couldn't ${ reason } .` )
271
- setDefault ( 'author_name' , 'Add & Commit Action' )
272
- setDefault ( 'author_email' , '[email protected] ' )
260
+ if ( typeof author == 'object' ) {
261
+ setDefault ( 'author_name' , author . name )
262
+ setDefault ( 'author_email' , author . email )
263
+ }
264
+
265
+ if ( ! getInput ( 'author_name' ) || ! getInput ( 'author_email' ) ) {
266
+ const reason = ! eventPath
267
+ ? 'event path'
268
+ : isPR
269
+ ? sha
270
+ ? 'fetch commit'
271
+ : 'find commit sha'
272
+ : ! event ?. head_commit
273
+ ? 'find commit'
274
+ : 'find commit author'
275
+ warning ( `Unable to fetch author info: couldn't ${ reason } .` )
276
+ setDefault ( 'author_name' , 'Add & Commit Action' )
277
+ setDefault ( 'author_email' , '[email protected] ' )
278
+ }
273
279
}
274
280
275
281
info (
0 commit comments