2021-12-11 04:59:31 -08:00
const github = require ( "@actions/github" ) ;
( async ( ) => {
try {
const token = process . argv [ 2 ] ;
const issueNumber = process . argv [ 3 ] ;
const username = process . argv [ 4 ] ;
const client = github . getOctokit ( token ) . rest ;
const issue = {
owner : "louislam" ,
repo : "uptime-kuma" ,
number : issueNumber ,
} ;
const labels = (
await client . issues . listLabelsOnIssue ( {
owner : issue . owner ,
repo : issue . repo ,
issue _number : issue . number
} )
) . data . map ( ( { name } ) => name ) ;
if ( labels . length === 0 ) {
console . log ( "Bad format here" ) ;
await client . issues . addLabels ( {
owner : issue . owner ,
repo : issue . repo ,
issue _number : issue . number ,
2022-04-17 00:27:35 -07:00
labels : [ "invalid-format" ]
2021-12-11 04:59:31 -08:00
} ) ;
// Add the issue closing comment
await client . issues . createComment ( {
owner : issue . owner ,
repo : issue . repo ,
issue _number : issue . number ,
2024-02-13 21:43:31 -08:00
body : ` @ ${ username } : Hello! :wave: \n \n This issue is being automatically closed because it does not follow the issue template. Please **DO NOT open blank issues and use our [issue-templates](https://github.com/louislam/uptime-kuma/issues/new/choose) instead**. \n Blank Issues do not contain the context nessesary for a good discussions. `
2021-12-11 04:59:31 -08:00
} ) ;
// Close the issue
await client . issues . update ( {
owner : issue . owner ,
repo : issue . repo ,
issue _number : issue . number ,
state : "closed"
} ) ;
} else {
console . log ( "Pass!" ) ;
}
} catch ( e ) {
console . log ( e ) ;
}
} ) ( ) ;