11const { getLatestCommitSha, parseManifestFile, updateManifestFile } = require ( './manifest-utils' ) ;
22
33module . exports = async function ( { github, core } ) {
4-
54 const manifestFile = 'get_all_manifests.sh' ;
6- const allComponents = parseManifestFile ( manifestFile ) ;
7-
8- // Filter to only components with branch@sha format
9- const componentsWithSha = new Map ( ) ;
10- for ( const [ componentName , componentInfo ] of allComponents ) {
11- if ( ! componentInfo . ref . includes ( '@' ) ) {
12- continue ;
13- }
14-
15- const refParts = componentInfo . ref . split ( '@' ) ;
16- if ( refParts . length !== 2 ) {
17- console . log ( `⚠️ Skipping ${ componentName } : invalid ref format "${ componentInfo . ref } " (expected "branch@sha")` ) ;
18- continue ;
19- }
20-
21- const [ branchRef , commitSha ] = refParts ;
22- if ( ! branchRef || ! commitSha ) {
23- console . log ( `⚠️ Skipping ${ componentName } : empty branch or SHA in ref "${ componentInfo . ref } "` ) ;
24- continue ;
5+ const parsedManifests = parseManifestFile ( manifestFile ) ;
6+
7+ const updates = [ ] ;
8+
9+ // Process both ODH and RHOAI platforms
10+ for ( const components of [ parsedManifests . odh , parsedManifests . rhoai ] ) {
11+ // Filter to only components with branch@sha format
12+ const componentsWithSha = [ ] ;
13+ for ( const componentInfo of components ) {
14+ if ( ! componentInfo . ref . includes ( '@' ) ) {
15+ continue ;
16+ }
17+
18+ const refParts = componentInfo . ref . split ( '@' ) ;
19+ if ( refParts . length !== 2 ) {
20+ console . log ( `⚠️ Skipping ${ componentInfo . platform } :${ componentInfo . componentName } : invalid ref format "${ componentInfo . ref } " (expected "branch@sha")` ) ;
21+ continue ;
22+ }
23+
24+ const [ branchRef , commitSha ] = refParts ;
25+ if ( ! branchRef || ! commitSha ) {
26+ console . log ( `⚠️ Skipping ${ componentInfo . platform } :${ componentInfo . componentName } : empty branch or SHA in ref "${ componentInfo . ref } "` ) ;
27+ continue ;
28+ }
29+
30+ componentsWithSha . push ( {
31+ ...componentInfo ,
32+ branchRef,
33+ commitSha
34+ } ) ;
2535 }
2636
27- componentsWithSha . set ( componentName , {
28- ...componentInfo ,
29- branchRef,
30- commitSha
31- } ) ;
32- }
33-
34- console . log ( `Found ${ componentsWithSha . size } components with branch@sha format` ) ;
37+ console . log ( `Found ${ componentsWithSha . length } ${ componentsWithSha . length > 0 ? componentsWithSha [ 0 ] . platform . toUpperCase ( ) : '' } components with branch@sha format` ) ;
3538
36- const updates = new Map ( ) ;
39+ for ( const manifest of componentsWithSha ) {
40+ console . log ( `Checking ${ manifest . platform } :${ manifest . componentName } (${ manifest . org } /${ manifest . repo } :${ manifest . branchRef } )...` ) ;
3741
38- for ( const [ componentName , manifest ] of componentsWithSha ) {
39- console . log ( `Checking ${ componentName } (${ manifest . org } /${ manifest . repo } :${ manifest . branchRef } )...` ) ;
42+ const latestSha = await getLatestCommitSha ( github , manifest . org , manifest . repo , manifest . branchRef ) ;
4043
41- const latestSha = await getLatestCommitSha ( github , manifest . org , manifest . repo , manifest . branchRef ) ;
44+ if ( latestSha && latestSha !== manifest . commitSha ) {
45+ console . log ( `Update needed for ${ manifest . platform } :${ manifest . componentName } : ${ manifest . commitSha . substring ( 0 , 8 ) } → ${ latestSha . substring ( 0 , 8 ) } ` ) ;
4246
43- if ( latestSha && latestSha !== manifest . commitSha ) {
44- console . log ( `Update needed for ${ componentName } : ${ manifest . commitSha . substring ( 0 , 8 ) } → ${ latestSha . substring ( 0 , 8 ) } ` ) ;
45-
46- updates . set ( componentName , {
47- org : manifest . org ,
48- repo : manifest . repo ,
49- newRef : `${ manifest . branchRef } @${ latestSha } ` ,
50- sourcePath : manifest . sourcePath ,
51- originalLine : manifest . originalLine ,
52- logMessage : `✅ Updated ${ componentName } : ${ manifest . commitSha . substring ( 0 , 8 ) } → ${ latestSha . substring ( 0 , 8 ) } `
53- } ) ;
54- } else {
55- console . log ( `No update needed for ${ componentName } ` ) ;
47+ updates . push ( {
48+ componentName : manifest . componentName ,
49+ org : manifest . org ,
50+ repo : manifest . repo ,
51+ newRef : `${ manifest . branchRef } @${ latestSha } ` ,
52+ sourcePath : manifest . sourcePath ,
53+ originalLine : manifest . originalLine ,
54+ logMessage : `✅ Updated ${ manifest . platform } :${ manifest . componentName } : ${ manifest . commitSha . substring ( 0 , 8 ) } → ${ latestSha . substring ( 0 , 8 ) } `
55+ } ) ;
56+ } else {
57+ console . log ( `No update needed for ${ manifest . platform } :${ manifest . componentName } ` ) ;
58+ }
5659 }
5760 }
5861
5962 // Set outputs
60- const hasUpdates = updates . size > 0 ;
63+ const hasUpdates = updates . length > 0 ;
6164 core . setOutput ( 'updates-needed' , hasUpdates ) ;
6265
6366 if ( ! hasUpdates ) {
@@ -69,5 +72,5 @@ module.exports = async function ({ github, core }) {
6972 console . log ( 'Updating manifest file...' ) ;
7073 updateManifestFile ( manifestFile , updates ) ;
7174
72- console . log ( `Successfully processed ${ updates . size } manifest updates` ) ;
75+ console . log ( `Successfully processed ${ updates . length } manifest updates` ) ;
7376}
0 commit comments