@@ -38,21 +38,29 @@ async function run(): Promise<void> {
38
38
const topMode = core . getInput ( 'top-mode' , { required : false } )
39
39
const topGlob = core . getInput ( 'top-glob' , { required : false } )
40
40
41
- let filtersYaml = ''
42
41
if ( topMode === 'true' ) {
43
42
// split at first /; sort by first item; group by first item
44
43
const groupedFiles = files . map ( f => f . filename . split ( '/' , 2 ) ) . sort ( ( a , b ) => a [ 0 ] . localeCompare ( b [ 0 ] ) )
45
44
// find unique first items
46
45
const topFolders = [ ...new Set ( groupedFiles . map ( f => f [ 0 ] ) ) ]
47
- // generate the YAML
48
- filtersYaml = jsyaml . dump ( topFolders . map ( f => ( { [ f ] : `${ f } /${ topGlob } ` } ) ) )
46
+ let matchedFolders = [ ]
47
+ for ( const folder of topFolders ) {
48
+ // generate the YAML
49
+ const filtersYaml = jsyaml . dump ( { [ folder ] : `${ folder } /${ topGlob } ` } )
50
+ const filter = new Filter ( filtersYaml )
51
+ const results = filter . match ( files )
52
+ if ( results [ folder ] . length > 0 ) {
53
+ matchedFolders . push ( folder )
54
+ }
55
+ exportTopModeResults ( matchedFolders )
56
+ }
49
57
} else {
50
58
const filtersInput = core . getInput ( 'filters' , { required : false } )
51
- filtersYaml = isPathInput ( filtersInput ) ? getConfigFileContent ( filtersInput ) : filtersInput
59
+ const filtersYaml = isPathInput ( filtersInput ) ? getConfigFileContent ( filtersInput ) : filtersInput
60
+ const filter = new Filter ( filtersYaml )
61
+ const results = filter . match ( files )
62
+ exportResults ( results , listFiles )
52
63
}
53
- const filter = new Filter ( filtersYaml )
54
- const results = filter . match ( files )
55
- exportResults ( results , listFiles )
56
64
} catch ( error : any ) {
57
65
core . setFailed ( error . message )
58
66
}
@@ -229,6 +237,17 @@ async function getChangedFilesFromApi(
229
237
}
230
238
}
231
239
240
+ function exportTopModeResults ( changedFolders : string [ ] ) : void {
241
+ core . info ( 'Matching folders:' )
242
+ for ( const folder of changedFolders ) {
243
+ core . info ( folder )
244
+ }
245
+
246
+ const changesJson = JSON . stringify ( changedFolders )
247
+ core . info ( `Changes output set to ${ changesJson } ` )
248
+ core . setOutput ( 'changes' , changesJson )
249
+ }
250
+
232
251
function exportResults ( results : FilterResults , format : ExportFormat ) : void {
233
252
core . info ( 'Results:' )
234
253
const changes = [ ]
0 commit comments