1- import type { Finding , ResolvedFiling , RepeatedFiling , FindingGroupIssue , Filing } from './types.d.js'
1+ import type { Finding , ResolvedFiling , RepeatedFiling , FindingGroupIssue , Filing , IssueResponse } from './types.d.js'
22import process from 'node:process'
33import core from '@actions/core'
44import { Octokit } from '@octokit/core'
@@ -11,7 +11,7 @@ import {isResolvedFiling} from './isResolvedFiling.js'
1111import { openIssue } from './openIssue.js'
1212import { reopenIssue } from './reopenIssue.js'
1313import { updateFilingsWithNewFindings } from './updateFilingsWithNewFindings.js'
14- import { OctokitResponse } from '@octokit/types'
14+ import { OctokitResponse } from '@octokit/types'
1515const OctokitWithThrottling = Octokit . plugin ( throttling )
1616
1717export default async function ( ) {
@@ -23,7 +23,7 @@ export default async function () {
2323 const cachedFilings : ( ResolvedFiling | RepeatedFiling ) [ ] = JSON . parse (
2424 core . getInput ( 'cached_filings' , { required : false } ) || '[]' ,
2525 )
26- const shouldOpenGroupedIssues = core . getBooleanInput ( " open_grouped_issues" )
26+ const shouldOpenGroupedIssues = core . getBooleanInput ( ' open_grouped_issues' )
2727 core . debug ( `Input: 'findings: ${ JSON . stringify ( findings ) } '` )
2828 core . debug ( `Input: 'repository: ${ repoWithOwner } '` )
2929 core . debug ( `Input: 'screenshot_repository: ${ screenshotRepo } '` )
@@ -56,7 +56,7 @@ export default async function () {
5656 const trackingIssueUrls : Record < string , string > = { }
5757
5858 for ( const filing of filings ) {
59- let response : OctokitResponse < any > | undefined ;
59+ let response : OctokitResponse < IssueResponse > | undefined
6060 try {
6161 if ( isResolvedFiling ( filing ) ) {
6262 // Close the filing’s issue (if necessary)
@@ -108,39 +108,28 @@ export default async function () {
108108 // Open tracking issues for groups with >1 new issue and link back from each
109109 // new issue
110110 if ( shouldOpenGroupedIssues ) {
111- for ( const [ problemShort , issues ] of Object . entries (
112- newIssuesByProblemShort ,
113- ) ) {
111+ for ( const [ problemShort , issues ] of Object . entries ( newIssuesByProblemShort ) ) {
114112 if ( issues . length > 1 ) {
115- const title : string = `${ problemShort } issues` ;
116- const body : string =
117- `# ${ problemShort } issues\n\n` +
118- issues . map ( ( issue ) => `- [ ] ${ issue . url } ` ) . join ( "\n" ) ;
113+ const title : string = `${ problemShort } issues`
114+ const body : string = `# ${ problemShort } issues\n\n` + issues . map ( issue => `- [ ] ${ issue . url } ` ) . join ( '\n' )
119115 try {
120- const trackingResponse = await octokit . request (
121- `POST /repos/${ repoWithOwner } /issues` ,
122- {
123- owner : repoWithOwner . split ( "/" ) [ 0 ] ,
124- repo : repoWithOwner . split ( "/" ) [ 1 ] ,
125- title,
126- body,
127- } ,
128- ) ;
129- const trackingUrl : string = trackingResponse . data . html_url ;
130- trackingIssueUrls [ problemShort ] = trackingUrl ;
131- core . info (
132- `Opened tracking issue for '${ problemShort } ' with ${ issues . length } issues.` ,
133- ) ;
116+ const trackingResponse = await octokit . request ( `POST /repos/${ repoWithOwner } /issues` , {
117+ owner : repoWithOwner . split ( '/' ) [ 0 ] ,
118+ repo : repoWithOwner . split ( '/' ) [ 1 ] ,
119+ title,
120+ body,
121+ } )
122+ const trackingUrl : string = trackingResponse . data . html_url
123+ trackingIssueUrls [ problemShort ] = trackingUrl
124+ core . info ( `Opened tracking issue for '${ problemShort } ' with ${ issues . length } issues.` )
134125 } catch ( error ) {
135- core . warning (
136- `Failed to open tracking issue for '${ problemShort } ': ${ error } ` ,
137- ) ;
126+ core . warning ( `Failed to open tracking issue for '${ problemShort } ': ${ error } ` )
138127 }
139128 }
140129 }
141130 }
142131
143- core . setOutput ( " filings" , JSON . stringify ( filings ) ) ;
144- core . debug ( `Output: 'filings: ${ JSON . stringify ( filings ) } '` ) ;
145- core . info ( "Finished 'file' action" ) ;
132+ core . setOutput ( ' filings' , JSON . stringify ( filings ) )
133+ core . debug ( `Output: 'filings: ${ JSON . stringify ( filings ) } '` )
134+ core . info ( "Finished 'file' action" )
146135}
0 commit comments