1- import type { Finding , ResolvedFiling , RepeatedFiling } from "./types.d.js" ;
1+ import type {
2+ Finding ,
3+ ResolvedFiling ,
4+ RepeatedFiling ,
5+ FindingGroupIssue ,
6+ Filing ,
7+ } from "./types.d.js" ;
28import process from "node:process" ;
39import core from "@actions/core" ;
410import { Octokit } from "@octokit/core" ;
@@ -11,7 +17,7 @@ import { isResolvedFiling } from "./isResolvedFiling.js";
1117import { openIssue } from "./openIssue.js" ;
1218import { reopenIssue } from "./reopenIssue.js" ;
1319import { updateFilingsWithNewFindings } from "./updateFilingsWithNewFindings.js" ;
14- import { OctokitResponse } from "@octokit/types" ;
20+ import type { OctokitResponse } from "@octokit/types" ;
1521const OctokitWithThrottling = Octokit . plugin ( throttling ) ;
1622
1723export default async function ( ) {
@@ -24,7 +30,7 @@ export default async function () {
2430 const cachedFilings : ( ResolvedFiling | RepeatedFiling ) [ ] = JSON . parse (
2531 core . getInput ( "cached_filings" , { required : false } ) || "[]" ,
2632 ) ;
27- const shouldOpenTrackingIssues = core . getBooleanInput ( "open_tracking_issues " ) ;
33+ const shouldOpenGroupedIssues = core . getBooleanInput ( "open_grouped_issues " ) ;
2834 core . debug ( `Input: 'findings: ${ JSON . stringify ( findings ) } '` ) ;
2935 core . debug ( `Input: 'repository: ${ repoWithOwner } '` ) ;
3036 core . debug ( `Input: 'cached_filings: ${ JSON . stringify ( cachedFilings ) } '` ) ;
@@ -55,8 +61,7 @@ export default async function () {
5561 const filings = updateFilingsWithNewFindings ( cachedFilings , findings ) ;
5662
5763 // Track new issues for grouping
58- const newIssuesByProblemShort : Record < string , { url : string ; id : number } [ ] > =
59- { } ;
64+ const newIssuesByProblemShort : Record < string , FindingGroupIssue [ ] > = { } ;
6065 const trackingIssueUrls : Record < string , string > = { } ;
6166
6267 for ( const filing of filings ) {
@@ -69,12 +74,13 @@ export default async function () {
6974 } else if ( isNewFiling ( filing ) ) {
7075 // Open a new issue for the filing
7176 response = await openIssue ( octokit , repoWithOwner , filing . findings [ 0 ] ) ;
72- ( filing as any ) . issue = { state : "open" } as Issue ;
77+ ( filing as Filing ) . issue = { state : "open" } as Issue ;
7378 // Track for grouping
74- if ( shouldOpenTrackingIssues ) {
79+ if ( shouldOpenGroupedIssues ) {
7580 const problemShort : string = filing . findings [ 0 ] . problemShort ;
76- if ( ! newIssuesByProblemShort [ problemShort ] )
81+ if ( ! newIssuesByProblemShort [ problemShort ] ) {
7782 newIssuesByProblemShort [ problemShort ] = [ ] ;
83+ }
7884 newIssuesByProblemShort [ problemShort ] . push ( {
7985 url : response . data . html_url ,
8086 id : response . data . number ,
@@ -102,12 +108,12 @@ export default async function () {
102108 }
103109
104110 // Open tracking issues for each root cause and link back from each newly-created issue
105- if ( shouldOpenTrackingIssues ) {
111+ if ( shouldOpenGroupedIssues ) {
106112 for ( const [ problemShort , issues ] of Object . entries (
107113 newIssuesByProblemShort ,
108- ) as [ string , { url : string ; id : number } [ ] ] [ ] ) {
114+ ) ) {
109115 if ( issues . length > 1 ) {
110- const title : string = `${ problemShort } issues` ;
116+ const title : string = `Accessibility tracking issue for all ${ problemShort } issues` ;
111117 const body : string =
112118 `# ${ problemShort } issues\n\n` +
113119 issues . map ( ( issue ) => `- [ ] ${ issue . url } ` ) . join ( "\n" ) ;
@@ -133,9 +139,9 @@ export default async function () {
133139 }
134140 }
135141 }
136-
137- core . setOutput ( "filings" , JSON . stringify ( filings ) ) ;
138- core . debug ( `Output: 'filings: ${ JSON . stringify ( filings ) } '` ) ;
139- core . info ( "Finished 'file' action" ) ;
140142 }
143+
144+ core . setOutput ( "filings" , JSON . stringify ( filings ) ) ;
145+ core . debug ( `Output: 'filings: ${ JSON . stringify ( filings ) } '` ) ;
146+ core . info ( "Finished 'file' action" ) ;
141147}
0 commit comments