@@ -71,58 +71,61 @@ export default async function () {
7171 if ( dryRun ) {
7272 if ( isResolvedFiling ( filing ) ) {
7373 dryRunCounts . close ++
74+ filing . issue . state = 'closed'
7475 core . info ( `[dry run] Would CLOSE issue: ${ filing . issue . url } ` )
7576 } else if ( isNewFiling ( filing ) ) {
7677 dryRunCounts . open ++
78+ ; ( filing as Filing ) . issue = { state : 'open' } as Issue
7779 core . info (
7880 `[dry run] Would OPEN a new issue for: ${ filing . findings [ 0 ] . problemShort } (${ filing . findings [ 0 ] . url } )` ,
7981 )
8082 } else if ( isRepeatedFiling ( filing ) ) {
8183 dryRunCounts . reopen ++
84+ filing . issue . state = 'reopened'
8285 core . info ( `[dry run] Would REOPEN issue: ${ filing . issue . url } ` )
8386 }
84- continue
85- }
86- if ( isResolvedFiling ( filing ) ) {
87- // Close the filing’s issue (if necessary)
88- response = await closeIssue ( octokit , new Issue ( filing . issue ) )
89- filing . issue . state = 'closed'
90- } else if ( isNewFiling ( filing ) ) {
91- // Open a new issue for the filing
92- response = await openIssue ( octokit , repoWithOwner , filing . findings [ 0 ] , screenshotRepo )
93- ; ( filing as Filing ) . issue = { state : 'open' } as Issue
87+ } else {
88+ if ( isResolvedFiling ( filing ) ) {
89+ // Close the filing's issue (if necessary)
90+ response = await closeIssue ( octokit , new Issue ( filing . issue ) )
91+ filing . issue . state = 'closed'
92+ } else if ( isNewFiling ( filing ) ) {
93+ // Open a new issue for the filing
94+ response = await openIssue ( octokit , repoWithOwner , filing . findings [ 0 ] , screenshotRepo )
95+ ; ( filing as Filing ) . issue = { state : 'open' } as Issue
9496
95- // Track for grouping
96- if ( shouldOpenGroupedIssues ) {
97- const problemShort : string = filing . findings [ 0 ] . problemShort
98- if ( ! newIssuesByProblemShort [ problemShort ] ) {
99- newIssuesByProblemShort [ problemShort ] = [ ]
97+ // Track for grouping
98+ if ( shouldOpenGroupedIssues ) {
99+ const problemShort : string = filing . findings [ 0 ] . problemShort
100+ if ( ! newIssuesByProblemShort [ problemShort ] ) {
101+ newIssuesByProblemShort [ problemShort ] = [ ]
102+ }
103+ newIssuesByProblemShort [ problemShort ] . push ( {
104+ url : response . data . html_url ,
105+ id : response . data . number ,
106+ } )
100107 }
101- newIssuesByProblemShort [ problemShort ] . push ( {
102- url : response . data . html_url ,
103- id : response . data . number ,
104- } )
108+ } else if ( isRepeatedFiling ( filing ) ) {
109+ // Reopen the filing's issue (if necessary) and update the body with the latest finding
110+ response = await reopenIssue (
111+ octokit ,
112+ new Issue ( filing . issue ) ,
113+ filing . findings [ 0 ] ,
114+ repoWithOwner ,
115+ screenshotRepo ,
116+ )
117+ filing . issue . state = 'reopened'
118+ }
119+ if ( response ?. data && filing . issue ) {
120+ // Update the filing with the latest issue data
121+ filing . issue . id = response . data . id
122+ filing . issue . nodeId = response . data . node_id
123+ filing . issue . url = response . data . html_url
124+ filing . issue . title = response . data . title
125+ core . info (
126+ `Set issue ${ response . data . title } (${ repoWithOwner } #${ response . data . number } ) state to ${ filing . issue . state } ` ,
127+ )
105128 }
106- } else if ( isRepeatedFiling ( filing ) ) {
107- // Reopen the filing's issue (if necessary) and update the body with the latest finding
108- response = await reopenIssue (
109- octokit ,
110- new Issue ( filing . issue ) ,
111- filing . findings [ 0 ] ,
112- repoWithOwner ,
113- screenshotRepo ,
114- )
115- filing . issue . state = 'reopened'
116- }
117- if ( response ?. data && filing . issue ) {
118- // Update the filing with the latest issue data
119- filing . issue . id = response . data . id
120- filing . issue . nodeId = response . data . node_id
121- filing . issue . url = response . data . html_url
122- filing . issue . title = response . data . title
123- core . info (
124- `Set issue ${ response . data . title } (${ repoWithOwner } #${ response . data . number } ) state to ${ filing . issue . state } ` ,
125- )
126129 }
127130 } catch ( error ) {
128131 core . setFailed ( `Failed on filing: ${ JSON . stringify ( filing , null , 2 ) } \n${ error } ` )
0 commit comments