@@ -10,18 +10,20 @@ const OctokitWithThrottling = Octokit.plugin(throttling);
1010export default async function ( ) {
1111 core . info ( "Started 'fix' action" ) ;
1212 /** @deprecated Use `issues` instead. */
13- const issueUrls : string [ ] = JSON . parse (
14- core . getInput ( ' issue_urls' , { required : false } ) || "[] "
13+ const issueUrls : string [ ] | null = JSON . parse (
14+ core . getInput ( " issue_urls" , { required : false } ) || "null "
1515 ) ;
16- const issues : IssueInput [ ] = JSON . parse (
17- core . getInput ( ' issues' , { required : false } ) || JSON . stringify ( issueUrls . map ( url => ( { url } ) ) )
16+ const issues : IssueInput [ ] | null = JSON . parse (
17+ core . getInput ( " issues" , { required : false } ) || "null"
1818 ) ;
19- if ( issues . length === 0 ) {
20- core . setFailed ( "Neither 'issues' nor 'issue_urls' was provided, but one is required." ) ;
19+ if ( issueUrls === null && issues === null ) {
20+ core . setFailed (
21+ "Neither 'issues' nor 'issue_urls' was provided, but one is required."
22+ ) ;
2123 process . exit ( 1 ) ;
2224 }
23- const repoWithOwner = core . getInput ( ' repository' , { required : true } ) ;
24- const token = core . getInput ( ' token' , { required : true } ) ;
25+ const repoWithOwner = core . getInput ( " repository" , { required : true } ) ;
26+ const token = core . getInput ( " token" , { required : true } ) ;
2527 core . debug ( `Input: 'issues: ${ JSON . stringify ( issues ) } '` ) ;
2628 core . debug ( `Input: 'issue_urls: ${ JSON . stringify ( issueUrls ) } '` ) ;
2729 core . debug ( `Input: 'repository: ${ repoWithOwner } '` ) ;
@@ -30,26 +32,34 @@ export default async function () {
3032 auth : token ,
3133 throttle : {
3234 onRateLimit : ( retryAfter , options , octokit , retryCount ) => {
33- octokit . log . warn ( `Request quota exhausted for request ${ options . method } ${ options . url } ` ) ;
35+ octokit . log . warn (
36+ `Request quota exhausted for request ${ options . method } ${ options . url } `
37+ ) ;
3438 if ( retryCount < 3 ) {
3539 octokit . log . info ( `Retrying after ${ retryAfter } seconds!` ) ;
3640 return true ;
3741 }
3842 } ,
3943 onSecondaryRateLimit : ( retryAfter , options , octokit , retryCount ) => {
40- octokit . log . warn ( `Secondary rate limit hit for request ${ options . method } ${ options . url } ` ) ;
44+ octokit . log . warn (
45+ `Secondary rate limit hit for request ${ options . method } ${ options . url } `
46+ ) ;
4147 if ( retryCount < 3 ) {
4248 octokit . log . info ( `Retrying after ${ retryAfter } seconds!` ) ;
4349 return true ;
4450 }
4551 } ,
46- }
52+ } ,
4753 } ) ;
48- for ( const issueInput of issues ) {
54+ const issueInputs : IssueInput [ ] =
55+ issues ?? issueUrls ?. map ( ( url ) => ( { url } ) ) ?? [ ] ;
56+ for ( const issueInput of issueInputs ) {
4957 try {
5058 const issue = new Issue ( issueInput ) ;
5159 await fixIssue ( octokit , issue ) ;
52- core . info ( `Assigned ${ issue . owner } /${ issue . repository } #${ issue . issueNumber } to Copilot!` ) ;
60+ core . info (
61+ `Assigned ${ issue . owner } /${ issue . repository } #${ issue . issueNumber } to Copilot!`
62+ ) ;
5363 } catch ( error ) {
5464 core . setFailed ( `Failed to assign ${ issueInput . url } to Copilot: ${ error } ` ) ;
5565 process . exit ( 1 ) ;
0 commit comments