@@ -7414,76 +7414,53 @@ async function getCommitBaseHead(context) {
74147414async function main (
74157415 context ,
74167416 client ,
7417- requiredChangePatterns ,
7418- preventModificationPatterns
7417+ requiredFileChanges = [ ] ,
7418+ preventFileChanges = [ ]
74197419) {
7420- if ( requiredChangePatterns && typeof requiredChangePatterns !== "object" ) {
7421- core . setFailed (
7422- "Please fill in the requiredChangePatterns names as an object"
7423- ) ;
7424- return ;
7425- }
7426-
7427- if (
7428- preventModificationPatterns &&
7429- typeof preventModificationPatterns !== "object"
7430- ) {
7431- core . setFailed (
7432- "Please fill in the preventModificationPatterns names as an object"
7433- ) ;
7434- return ;
7435- }
7436-
74377420 const basehead = await getCommitBaseHead ( context ) ;
74387421 const commitChanges = await client . rest . repos . compareCommitsWithBasehead ( {
74397422 ...context . repo ,
7440- basehead
7423+ basehead,
74417424 } ) ;
7442- const changedFileNames = commitChanges . data . files . map ( ( f ) => f . filename ) ;
7425+ const changedFiles = commitChanges . data . files . map ( ( f ) => f . filename ) ;
74437426
7444- const requiredFileChangesIncluded = ! ! requiredChangePatterns
7445- ? requiredChangePatterns . every (
7446- ( pattern ) => ! ! changedFileNames . find ( ( file ) => minimatch ( file , pattern ) )
7447- )
7448- : true ;
7427+ const requiredFileChangesIncluded =
7428+ requiredFileChanges . every (
7429+ ( pattern ) => ! ! changedFiles . find ( ( file ) => minimatch ( file , pattern ) )
7430+ ) ;
74497431
7450- const preventedFileChangedIncluded = ! ! preventModificationPatterns
7451- ? preventModificationPatterns . every (
7452- ( pattern ) => ! ! changedFileNames . find ( ( file ) => minimatch ( file , pattern ) )
7453- )
7454- : false ;
7432+ const preventedFileChangedIncluded =
7433+ preventFileChanges . every (
7434+ ( pattern ) => ! ! changedFiles . find ( ( file ) => minimatch ( file , pattern ) )
7435+ ) ;
74557436
74567437 if ( requiredFileChangesIncluded && ! preventedFileChangedIncluded ) {
74577438 core . setOutput ( "success" , true ) ;
7458- return ;
7439+ return true ;
74597440 }
74607441
74617442 core . setFailed ( `
74627443 Files changed:\n
7463- ${ JSON . stringify ( changedFileNames , null , 2 ) } \n\n
7444+ ${ JSON . stringify ( changedFiles , null , 2 ) } \n\n
74647445 Please ensure you have changed all files that match the following patterns:\n
7465- ${ JSON . stringify ( requiredFileChangesIncluded , null , 2 ) } \n\n
7446+ ${ JSON . stringify ( requiredFileChanges , null , 2 ) } \n\n
74667447 Please ensure you have not changed any of the files that match the following patterns:\n
7467- ${ JSON . stringify ( preventedFileChangedIncluded , null , 2 ) } \n\n
7448+ ${ JSON . stringify ( preventFileChanges , null , 2 ) } \n\n
74687449 ` ) ;
7450+ return false ;
74697451}
74707452
74717453async function run ( ) {
74727454 const githubToken = core . getInput ( "token" , { required : true } ) ;
7473- const requiredChangePatterns = JSON . parse (
7474- core . getInput ( "require-change-file-patterns" , { required : false } )
7475- ) ;
7476- const preventModificationPatterns = JSON . parse (
7477- core . getInput ( "prevent-modification-file-patterns" , { required : false } )
7478- ) ;
7455+ const requiredFileChanges = core . getMultilineInput ( "require-changes-to" , {
7456+ required : false ,
7457+ } ) ;
7458+ const preventFileChanges = core . getMultilineInput ( "prevent-changes-to" , {
7459+ required : false ,
7460+ } ) ;
74797461
74807462 const client = getOctokit ( githubToken ) ;
7481- await main (
7482- context ,
7483- client ,
7484- requiredChangePatterns ,
7485- preventModificationPatterns
7486- ) ;
7463+ await main ( context , client , requiredFileChanges , preventFileChanges ) ;
74877464}
74887465
74897466run ( ) ;
0 commit comments