@@ -121,6 +121,15 @@ async function getChecksFor(
121121 return removeExcluded ( exclusions , checkInfos ) ;
122122}
123123
124+ /** Gets the current list of release branches. */
125+ async function getReleaseBranches ( client : ApiClient ) : Promise < string [ ] > {
126+ const refs = await client . rest . git . listMatchingRefs ( {
127+ ...codeqlActionRepo ,
128+ ref : "heads/releases/v" ,
129+ } ) ;
130+ return refs . data . map ( ( ref ) => ref . ref ) . sort ( ) ;
131+ }
132+
124133async function main ( ) : Promise < void > {
125134 const { values : options } = parseArgs ( {
126135 options : {
@@ -160,6 +169,38 @@ async function main(): Promise<void> {
160169 const checkInfos = await getChecksFor ( client , options . ref ) ;
161170 const checkNames = new Set ( checkInfos . map ( ( info ) => info . context ) ) ;
162171
172+ // Retrieve the refs of the release branches.
173+ const releaseBranches = await getReleaseBranches ( client ) ;
174+ console . info (
175+ `Found ${ releaseBranches . length } release branches: ${ releaseBranches . join ( ", " ) } ` ,
176+ ) ;
177+
178+ for ( const releaseBranchRef of releaseBranches ) {
179+ // Sanity check that the ref name is in the expected format and extract the major version.
180+ const releaseBranchMatch = releaseBranchRef . match (
181+ / ^ r e f s \/ h e a d s \/ ( r e l e a s e s \/ v ( \d + ) ) / ,
182+ ) ;
183+ if ( ! releaseBranchMatch ) {
184+ console . warn (
185+ `Branch ref '${ releaseBranchRef } ' not in the expected format.` ,
186+ ) ;
187+ continue ;
188+ }
189+ const releaseBranch = releaseBranchMatch [ 1 ] ;
190+ const releaseBranchMajor = Number . parseInt ( releaseBranchMatch [ 2 ] ) ;
191+
192+ // Update the required checks for this major version if it is still supported.
193+ if ( releaseBranchMajor < OLDEST_SUPPORTED_MAJOR_VERSION ) {
194+ console . info (
195+ `Skipping '${ releaseBranch } ' since it is older than v${ OLDEST_SUPPORTED_MAJOR_VERSION } ` ,
196+ ) ;
197+ continue ;
198+ } else {
199+ console . info ( `Updating '${ releaseBranch } '...` ) ;
200+
201+ }
202+ }
203+
163204 process . exit ( 0 ) ;
164205}
165206
0 commit comments