@@ -7568,17 +7568,9 @@ const {
doCreateIssue ,
doCreateIssue ,
} = _ _webpack _require _ _ ( 9932 ) ;
} = _ _webpack _require _ _ ( 9932 ) ;
const {
const { doQueryIssues , getIssuesInMonth , getCreatedMonth } = _ _webpack _require _ _ ( 197 ) ;
doQueryIssues ,
getIssuesInMonth ,
getCreatedMonth ,
} = _ _webpack _require _ _ ( 197 ) ;
const {
const { dealStringToArr , matchKeyword , getPreMonth } = _ _webpack _require _ _ ( 6254 ) ;
dealStringToArr ,
matchKeyword ,
getPreMonth
} = _ _webpack _require _ _ ( 6254 ) ;
// **************************************************************************
// **************************************************************************
var dayjs = _ _webpack _require _ _ ( 7401 ) ;
var dayjs = _ _webpack _require _ _ ( 7401 ) ;
@@ -7589,19 +7581,19 @@ dayjs.extend(utc);
const token = core . getInput ( 'token' ) ;
const token = core . getInput ( 'token' ) ;
const octokit = new Octokit ( { auth : ` token ${ token } ` } ) ;
const octokit = new Octokit ( { auth : ` token ${ token } ` } ) ;
let direction = core . getInput ( " direction" ) ;
let direction = core . getInput ( ' direction' ) ;
direction = direction === 'desc' ? 'desc' : 'asc' ;
direction = direction === 'desc' ? 'desc' : 'asc' ;
const commentAuth = core . getInput ( " comment-auth" ) ;
const commentAuth = core . getInput ( ' comment-auth' ) ;
const bodyIncludes = core . getInput ( 'body-includes' ) ;
const bodyIncludes = core . getInput ( 'body-includes' ) ;
const titleIncludes = core . getInput ( 'title-includes' ) ;
const titleIncludes = core . getInput ( 'title-includes' ) ;
const assigneeIncludes = core . getInput ( 'assignee-includes' ) ;
const assigneeIncludes = core . getInput ( 'assignee-includes' ) ;
let issueState = core . getInput ( " issue-state" ) || 'open' ;
let issueState = core . getInput ( ' issue-state' ) || 'open' ;
if ( issueState != 'all' && issueState != 'closed' ) {
if ( issueState != 'all' && issueState != 'closed' ) {
issueState = 'open' ;
issueState = 'open' ;
}
}
const inactiveLabel = core . getInput ( " inactive-label" ) || 'inactive' ;
const inactiveLabel = core . getInput ( ' inactive-label' ) || 'inactive' ;
// **************************************************************************
// **************************************************************************
async function doCheckInactive ( owner , repo , labels ) {
async function doCheckInactive ( owner , repo , labels ) {
@@ -7615,8 +7607,8 @@ async function doCheckInactive (owner, repo, labels) {
} ) ;
} ) ;
if ( ! arr . includes ( inactiveLabel ) ) {
if ( ! arr . includes ( inactiveLabel ) ) {
await doAddLabels ( owner , repo , issues [ i ] . number , inactiveLabel ) ;
await doAddLabels ( owner , repo , issues [ i ] . number , inactiveLabel ) ;
if ( core . getInput ( " body" ) ) {
if ( core . getInput ( ' body' ) ) {
await doCreateComment ( owner , repo , issues [ i ] . number , core . getInput ( " body" ) ) ;
await doCreateComment ( owner , repo , issues [ i ] . number , core . getInput ( ' body' ) ) ;
}
}
} else {
} else {
core . info ( ` Actions: [add-inactive] issue ${ issues [ i ] . number } has label! ` ) ;
core . info ( ` Actions: [add-inactive] issue ${ issues [ i ] . number } has label! ` ) ;
@@ -7625,7 +7617,7 @@ async function doCheckInactive (owner, repo, labels) {
} else {
} else {
core . info ( ` Actions: [query-issues] empty! ` ) ;
core . info ( ` Actions: [query-issues] empty! ` ) ;
}
}
} ;
}
/**
/**
* 检查 issue 是否满足条件,满足返回 true
* 检查 issue 是否满足条件,满足返回 true
@@ -7637,7 +7629,7 @@ async function doCheckIssue (owner, repo, issueNumber) {
const issue = await octokit . issues . get ( {
const issue = await octokit . issues . get ( {
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber
issue _number : issueNumber ,
} ) ;
} ) ;
if ( ! ! checkResult && assigneeIncludes ) {
if ( ! ! checkResult && assigneeIncludes ) {
@@ -7648,32 +7640,30 @@ async function doCheckIssue (owner, repo, issueNumber) {
checkResult = true ;
checkResult = true ;
checkAssignee = true ;
checkAssignee = true ;
}
}
} )
} ) ;
! checkAssignee ? checkResult = false : null ;
! checkAssignee ? ( checkResult = false ) : null ;
}
}
if ( ! ! checkResult && titleIncludes ) {
if ( ! ! checkResult && titleIncludes ) {
const titleArr = titleIncludes . split ( '/' ) ;
const titleArr = titleIncludes . split ( '/' ) ;
const keyword1 = dealStringToArr ( titleArr [ 0 ] ) ;
const keyword1 = dealStringToArr ( titleArr [ 0 ] ) ;
const keyword2 = dealStringToArr ( titleArr [ 1 ] ) ;
const keyword2 = dealStringToArr ( titleArr [ 1 ] ) ;
checkResult =
checkResult = keyword2 . length
keyword2 . length ?
? matchKeyword ( issue . data . title , keyword1 ) && matchKeyword ( issue . data . title , keyword2 )
matchKeyword ( issue . data . title , keyword1 ) && matchKeyword ( issue . data . title , keyword2 ) :
: matchKeyword ( issue . data . title , keyword1 ) ;
matchKeyword ( issue . data . title , keyword1 ) ;
}
}
if ( ! ! checkResult && bodyIncludes ) {
if ( ! ! checkResult && bodyIncludes ) {
const bodyArr = bodyIncludes . split ( '/' ) ;
const bodyArr = bodyIncludes . split ( '/' ) ;
const keyword1 = dealStringToArr ( bodyArr [ 0 ] ) ;
const keyword1 = dealStringToArr ( bodyArr [ 0 ] ) ;
const keyword2 = dealStringToArr ( bodyArr [ 1 ] ) ;
const keyword2 = dealStringToArr ( bodyArr [ 1 ] ) ;
checkResult =
checkResult = keyword2 . length
keyword2 . length ?
? matchKeyword ( issue . data . body , keyword1 ) && matchKeyword ( issue . data . body , keyword2 )
matchKeyword ( issue . data . body , keyword1 ) && matchKeyword ( issue . data . body , keyword2 ) :
: matchKeyword ( issue . data . body , keyword1 ) ;
matchKeyword ( issue . data . body , keyword1 ) ;
}
}
core . info ( ` Actions: [check-issue][ ${ ! ! checkResult } ] success! ` ) ;
core . info ( ` Actions: [check-issue][ ${ ! ! checkResult } ] success! ` ) ;
core . setOutput ( " check-result" , ! ! checkResult ) ;
core . setOutput ( ' check-result' , ! ! checkResult ) ;
} ;
}
async function doCloseIssues ( owner , repo , labels ) {
async function doCloseIssues ( owner , repo , labels ) {
const issues = await doQueryIssues ( owner , repo , labels , 'open' ) ;
const issues = await doQueryIssues ( owner , repo , labels , 'open' ) ;
@@ -7681,20 +7671,20 @@ async function doCloseIssues (owner, repo, labels) {
if ( issues . length ) {
if ( issues . length ) {
for ( let i = 0 ; i < issues . length ; i ++ ) {
for ( let i = 0 ; i < issues . length ; i ++ ) {
await doCloseIssue ( owner , repo , issues [ i ] . number ) ;
await doCloseIssue ( owner , repo , issues [ i ] . number ) ;
if ( core . getInput ( " body" ) ) {
if ( core . getInput ( ' body' ) ) {
await doCreateComment ( owner , repo , issues [ i ] . number , core . getInput ( " body" ) ) ;
await doCreateComment ( owner , repo , issues [ i ] . number , core . getInput ( ' body' ) ) ;
}
}
}
}
} else {
} else {
core . info ( ` Actions: [query-issues] empty! ` ) ;
core . info ( ` Actions: [query-issues] empty! ` ) ;
}
}
} ;
}
async function doFindComments ( owner , repo , issueNumber ) {
async function doFindComments ( owner , repo , issueNumber ) {
const res = await octokit . issues . listComments ( {
const res = await octokit . issues . listComments ( {
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber
issue _number : issueNumber ,
} ) ;
} ) ;
core . info ( ` Actions: [find-comments][ ${ issueNumber } ] success! ` ) ;
core . info ( ` Actions: [find-comments][ ${ issueNumber } ] success! ` ) ;
let comments = [ ] ;
let comments = [ ] ;
@@ -7707,15 +7697,15 @@ async function doFindComments (owner, repo, issueNumber) {
auth : item . user . login ,
auth : item . user . login ,
body : item . body ,
body : item . body ,
created : item . created _at ,
created : item . created _at ,
updated : item . updated _at
updated : item . updated _at ,
} )
} ) ;
if ( direction === 'desc' ) {
if ( direction === 'desc' ) {
comments . reverse ( ) ;
comments . reverse ( ) ;
}
}
}
}
} )
} ) ;
core . setOutput ( " comments" , comments ) ;
core . setOutput ( ' comments' , comments ) ;
} ;
}
async function doLockIssues ( owner , repo , labels ) {
async function doLockIssues ( owner , repo , labels ) {
const issues = await doQueryIssues ( owner , repo , labels , issueState ) ;
const issues = await doQueryIssues ( owner , repo , labels , issueState ) ;
@@ -7723,18 +7713,18 @@ async function doLockIssues (owner, repo, labels) {
if ( issues . length ) {
if ( issues . length ) {
for ( let i = 0 ; i < issues . length ; i ++ ) {
for ( let i = 0 ; i < issues . length ; i ++ ) {
await doLockIssue ( owner , repo , issues [ i ] . number ) ;
await doLockIssue ( owner , repo , issues [ i ] . number ) ;
if ( core . getInput ( " body" ) ) {
if ( core . getInput ( ' body' ) ) {
await doCreateComment ( owner , repo , issues [ i ] . number , core . getInput ( " body" ) ) ;
await doCreateComment ( owner , repo , issues [ i ] . number , core . getInput ( ' body' ) ) ;
}
}
}
}
} else {
} else {
core . info ( ` Actions: [query-issues] empty! ` ) ;
core . info ( ` Actions: [query-issues] empty! ` ) ;
}
}
} ;
}
async function doMonthStatistics ( owner , repo , labels , assignees ) {
async function doMonthStatistics ( owner , repo , labels , assignees ) {
const countLables = core . getInput ( " count-lables" ) ;
const countLables = core . getInput ( ' count-lables' ) ;
const countComments = core . getInput ( " count-comments" ) ;
const countComments = core . getInput ( ' count-comments' ) ;
const thisMonth = dayjs . utc ( ) . month ( ) + 1 ;
const thisMonth = dayjs . utc ( ) . month ( ) + 1 ;
const year = thisMonth == 1 ? dayjs . utc ( ) . year ( ) - 1 : dayjs . utc ( ) . year ( ) ;
const year = thisMonth == 1 ? dayjs . utc ( ) . year ( ) - 1 : dayjs . utc ( ) . year ( ) ;
@@ -7742,17 +7732,13 @@ async function doMonthStatistics (owner, repo, labels, assignees) {
const month = getPreMonth ( thisMonth ) ;
const month = getPreMonth ( thisMonth ) ;
const showMonth = month < 10 ? ` 0 ${ month } ` : month ;
const showMonth = month < 10 ? ` 0 ${ month } ` : month ;
let issues = await getIssuesInMonth (
let issues = await getIssuesInMonth ( owner , repo , thisMonth ) ;
owner ,
repo ,
thisMonth
) ;
if ( issues . length == 0 ) {
if ( issues . length == 0 ) {
core . info ( ` Actions: [query-issues- ${ month } ] empty! ` ) ;
core . info ( ` Actions: [query-issues- ${ month } ] empty! ` ) ;
return false ;
return false ;
}
}
issues = issues . filter ( i => {
issues = issues . filter ( i => {
return getCreatedMonth ( i . created _at ) == month
return getCreatedMonth ( i . created _at ) == month ;
} ) ;
} ) ;
let total = issues . length ;
let total = issues . length ;
let totalIssues = [ ... issues ] ;
let totalIssues = [ ... issues ] ;
@@ -7777,10 +7763,12 @@ async function doMonthStatistics (owner, repo, labels, assignees) {
} else {
} else {
labelsTotals [ l . name ] = 1 ;
labelsTotals [ l . name ] = 1 ;
}
}
} )
} ) ;
}
}
}
}
let now = dayjs ( ) . utc ( ) . format ( 'YYYY-MM-DD HH:mm:ss' ) ;
let now = dayjs ( )
. utc ( )
. format ( 'YYYY-MM-DD HH:mm:ss' ) ;
let body = `
let body = `
- Created time: ${ now }
- Created time: ${ now }
@@ -7802,8 +7790,8 @@ async function doMonthStatistics (owner, repo, labels, assignees) {
for ( var lab in labelsTotals ) {
for ( var lab in labelsTotals ) {
labelsArr . push ( {
labelsArr . push ( {
labelName : lab ,
labelName : lab ,
number : labelsTotals [ lab ]
number : labelsTotals [ lab ] ,
} )
} ) ;
}
}
labelsArr . sort ( ( a , b ) => b . number - a . number ) ;
labelsArr . sort ( ( a , b ) => b . number - a . number ) ;
let labelsTitle = `
let labelsTitle = `
@@ -7813,12 +7801,16 @@ async function doMonthStatistics (owner, repo, labels, assignees) {
<tr>
<tr>
<th>Name</th>
<th>Name</th>
<th>Number</th>
<th>Number</th>
</tr> `
</tr> ` ;
let labelsBody = '' ;
let labelsBody = '' ;
labelsArr . forEach ( it => {
labelsArr . forEach ( it => {
labelsBody += ` <tr><td> ${ it . labelName } </td><td> ${ it . number } </td></tr> `
labelsBody += ` <tr><td> ${ it . labelName } </td><td> ${ it . number } </td></tr> ` ;
} )
} ) ;
body = body + labelsTitle + labelsBody + ` </table>
body =
body +
labelsTitle +
labelsBody +
` </table>
` ;
` ;
}
}
@@ -7837,7 +7829,7 @@ async function doMonthStatistics (owner, repo, labels, assignees) {
<th>Number</th>
<th>Number</th>
<th>State</th>
<th>State</th>
</tr>
</tr>
`
` ;
let commentBody = '' ;
let commentBody = '' ;
maxComments . forEach ( ( it , ind ) => {
maxComments . forEach ( ( it , ind ) => {
commentBody += ` <tr>
commentBody += ` <tr>
@@ -7845,13 +7837,13 @@ async function doMonthStatistics (owner, repo, labels, assignees) {
<td> ${ it . number } </td>
<td> ${ it . number } </td>
<td> ${ it . title } </td>
<td> ${ it . title } </td>
<td> ${ it . comments } </td>
<td> ${ it . comments } </td>
<td> ${ it . state } </td></tr> `
<td> ${ it . state } </td></tr> ` ;
} )
} ) ;
body = body + commentTitle + commentBody + '</table>' ;
body = body + commentTitle + commentBody + '</table>' ;
}
}
await doCreateIssue ( owner , repo , title , body , labels , assignees ) ;
await doCreateIssue ( owner , repo , title , body , labels , assignees ) ;
} ;
}
// **************************************************************************
// **************************************************************************
module . exports = {
module . exports = {
@@ -7875,35 +7867,20 @@ const github = __webpack_require__(5438);
const { Octokit } = _ _webpack _require _ _ ( 5375 ) ;
const { Octokit } = _ _webpack _require _ _ ( 5375 ) ;
// **************************************************************************
// **************************************************************************
const ALLREACTIONS = [
const ALLREACTIONS = [ '+1' , '-1' , 'laugh' , 'confused' , 'heart' , 'hooray' , 'rocket' , 'eyes' ] ;
"+1" ,
"-1" ,
"laugh" ,
"confused" ,
"heart" ,
"hooray" ,
"rocket" ,
"eyes" ,
] ;
const {
const { doQueryIssues } = _ _webpack _require _ _ ( 197 ) ;
doQueryIssues
} = _ _webpack _require _ _ ( 197 ) ;
const {
const { dealStringToArr , dealRandomAssignees , testDuplicate } = _ _webpack _require _ _ ( 6254 ) ;
dealStringToArr ,
dealRandomAssignees ,
testDuplicate ,
} = _ _webpack _require _ _ ( 6254 ) ;
// **************************************************************************
// **************************************************************************
const token = core . getInput ( 'token' ) ;
const token = core . getInput ( 'token' ) ;
const octokit = new Octokit ( { auth : ` token ${ token } ` } ) ;
const octokit = new Octokit ( { auth : ` token ${ token } ` } ) ;
const context = github . context ;
const context = github . context ;
const contents = core . getInput ( " contents" ) ;
const contents = core . getInput ( ' contents' ) ;
const randomTo = core . getInput ( " random-to" ) ;
const randomTo = core . getInput ( ' random-to' ) ;
// **************************************************************************
// **************************************************************************
async function doAddAssignees ( owner , repo , issueNumber , assignees ) {
async function doAddAssignees ( owner , repo , issueNumber , assignees ) {
@@ -7912,45 +7889,45 @@ async function doAddAssignees (owner, repo, issueNumber, assignees) {
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber ,
issue _number : issueNumber ,
assignees : arr
assignees : arr ,
} ) ;
} ) ;
core . info ( ` Actions: [add-assignees][ ${ arr } ] success! ` ) ;
core . info ( ` Actions: [add-assignees][ ${ arr } ] success! ` ) ;
} ;
}
async function doAddLabels ( owner , repo , issueNumber , labels ) {
async function doAddLabels ( owner , repo , issueNumber , labels ) {
await octokit . issues . addLabels ( {
await octokit . issues . addLabels ( {
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber ,
issue _number : issueNumber ,
labels : dealStringToArr ( labels )
labels : dealStringToArr ( labels ) ,
} ) ;
} ) ;
core . info ( ` Actions: [add-labels][ ${ labels } ] success! ` ) ;
core . info ( ` Actions: [add-labels][ ${ labels } ] success! ` ) ;
} ;
}
async function doCloseIssue ( owner , repo , issueNumber ) {
async function doCloseIssue ( owner , repo , issueNumber ) {
await octokit . issues . update ( {
await octokit . issues . update ( {
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber ,
issue _number : issueNumber ,
state : 'closed'
state : 'closed' ,
} ) ;
} ) ;
core . info ( ` Actions: [close-issue][ ${ issueNumber } ] success! ` ) ;
core . info ( ` Actions: [close-issue][ ${ issueNumber } ] success! ` ) ;
} ;
}
async function doCreateComment ( owner , repo , issueNumber , body ) {
async function doCreateComment ( owner , repo , issueNumber , body ) {
const { data } = await octokit . issues . createComment ( {
const { data } = await octokit . issues . createComment ( {
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber ,
issue _number : issueNumber ,
body
body ,
} ) ;
} ) ;
core . info ( ` Actions: [create-comment][ ${ body } ] success! ` ) ;
core . info ( ` Actions: [create-comment][ ${ body } ] success! ` ) ;
core . setOutput ( " comment-id" , data . id ) ;
core . setOutput ( ' comment-id' , data . id ) ;
if ( contents ) {
if ( contents ) {
await doCreateCommentContent ( owner , repo , data . id , dealStringToArr ( contents ) ) ;
await doCreateCommentContent ( owner , repo , data . id , dealStringToArr ( contents ) ) ;
}
}
} ;
}
async function doCreateCommentContent ( owner , repo , commentId , contents ) {
async function doCreateCommentContent ( owner , repo , commentId , contents ) {
if ( contents . length ) {
if ( contents . length ) {
@@ -7960,13 +7937,13 @@ async function doCreateCommentContent(owner, repo, commentId, contents) {
owner ,
owner ,
repo ,
repo ,
comment _id : commentId ,
comment _id : commentId ,
content : item
content : item ,
} ) ;
} ) ;
core . info ( ` Actions: [create-reactions][ ${ item } ] success! ` ) ;
core . info ( ` Actions: [create-reactions][ ${ item } ] success! ` ) ;
}
}
} )
} ) ;
}
}
}
} ;
async function doCreateIssue ( owner , repo , title , body , labels , assignees ) {
async function doCreateIssue ( owner , repo , title , body , labels , assignees ) {
let params = {
let params = {
@@ -7980,12 +7957,12 @@ async function doCreateIssue (owner, repo, title, body, labels, assignees) {
const { data } = await octokit . issues . create ( params ) ;
const { data } = await octokit . issues . create ( params ) ;
core . info ( ` Actions: [create-issue][ ${ title } ] success! ` ) ;
core . info ( ` Actions: [create-issue][ ${ title } ] success! ` ) ;
core . setOutput ( " issue-number" , data . number ) ;
core . setOutput ( ' issue-number' , data . number ) ;
if ( contents ) {
if ( contents ) {
await doCreateIssueContent ( owner , repo , data . number , dealStringToArr ( contents ) ) ;
await doCreateIssueContent ( owner , repo , data . number , dealStringToArr ( contents ) ) ;
}
}
} ;
}
async function doCreateIssueContent ( owner , repo , issueNumber , contents ) {
async function doCreateIssueContent ( owner , repo , issueNumber , contents ) {
if ( contents . length ) {
if ( contents . length ) {
@@ -7995,22 +7972,22 @@ async function doCreateIssueContent(owner, repo, issueNumber, contents) {
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber ,
issue _number : issueNumber ,
content : item
content : item ,
} ) ;
} ) ;
core . info ( ` Actions: [create-reactions][ ${ item } ] success! ` ) ;
core . info ( ` Actions: [create-reactions][ ${ item } ] success! ` ) ;
}
}
} )
} ) ;
}
}
}
} ;
async function doDeleteComment ( owner , repo , commentId ) {
async function doDeleteComment ( owner , repo , commentId ) {
await octokit . issues . deleteComment ( {
await octokit . issues . deleteComment ( {
owner ,
owner ,
repo ,
repo ,
comment _id : commentId
comment _id : commentId ,
} ) ;
} ) ;
core . info ( ` Actions: [delete-comment][ ${ commentId } ] success! ` ) ;
core . info ( ` Actions: [delete-comment][ ${ commentId } ] success! ` ) ;
} ;
}
async function doLockIssue ( owner , repo , issueNumber ) {
async function doLockIssue ( owner , repo , issueNumber ) {
await octokit . issues . lock ( {
await octokit . issues . lock ( {
@@ -8019,7 +7996,7 @@ async function doLockIssue (owner, repo, issueNumber) {
issue _number : issueNumber ,
issue _number : issueNumber ,
} ) ;
} ) ;
core . info ( ` Actions: [lock-issue][ ${ issueNumber } ] success! ` ) ;
core . info ( ` Actions: [lock-issue][ ${ issueNumber } ] success! ` ) ;
} ;
}
async function doMarkDuplicate ( owner , repo , labels ) {
async function doMarkDuplicate ( owner , repo , labels ) {
if ( context . eventName != 'issue_comment' ) {
if ( context . eventName != 'issue_comment' ) {
@@ -8028,18 +8005,39 @@ async function doMarkDuplicate (owner, repo, labels) {
}
}
if ( context . payload . action == 'created' || context . payload . action == 'edited' ) {
if ( context . payload . action == 'created' || context . payload . action == 'edited' ) {
const duplicateCommand = core . getInput ( " duplicate-command" ) ;
const duplicateCommand = core . getInput ( ' duplicate-command' ) ;
const duplicateLabels = core . getInput ( " duplicate-labels" ) ;
const duplicateLabels = core . getInput ( ' duplicate-labels' ) ;
const removeLables = core . getInput ( " remove-labels" ) ;
const removeLables = core . getInput ( ' remove-labels' ) ;
const closeIssue = core . getInput ( " close-issue" ) ;
const closeIssue = core . getInput ( ' close-issue' ) ;
const allowPermissions = core . getInput ( 'allow-permissions' ) ;
const commentId = context . payload . comment . id ;
const commentId = context . payload . comment . id ;
const commentBody = context . payload . comment . body ;
const commentBody = context . payload . comment . body ;
const commentUser = context . payload . comment . user . login ;
const issueNumber = context . payload . issue . number ;
const issueNumber = context . payload . issue . number ;
const ifCommandInput = ! ! duplicateCommand ;
const ifCommandInput = ! ! duplicateCommand ;
if ( ! commentBody . includes ( '?' ) && ( ( ifCommandInput && commentBody . startsWith ( duplicateCommand ) && commentBody . split ( ' ' ) [ 0 ] == duplicateCommand ) || testDuplicate ( commentBody ) ) ) {
if ( allowPermissions ) {
const res = await octokit . repos . getCollaboratorPermissionLevel ( {
owner ,
repo ,
username : commentUser ,
} ) ;
const { permission } = res . data ;
if ( ! allowPermissions . includes ( permission ) ) {
core . info ( ` The user ${ commentUser } is not allow! ` ) ;
return false ;
}
}
if (
! commentBody . includes ( '?' ) &&
( ( ifCommandInput &&
commentBody . startsWith ( duplicateCommand ) &&
commentBody . split ( ' ' ) [ 0 ] == duplicateCommand ) ||
testDuplicate ( commentBody ) )
) {
if ( ifCommandInput ) {
if ( ifCommandInput ) {
const nextBody = commentBody . replace ( duplicateCommand , 'Duplicate of' ) ;
const nextBody = commentBody . replace ( duplicateCommand , 'Duplicate of' ) ;
await doUpdateComment ( owner , repo , commentId , nextBody , 'replace' , true ) ;
await doUpdateComment ( owner , repo , commentId , nextBody , 'replace' , true ) ;
@@ -8050,11 +8048,13 @@ async function doMarkDuplicate (owner, repo, labels) {
const issue = await octokit . issues . get ( {
const issue = await octokit . issues . get ( {
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber
issue _number : issueNumber ,
} ) ;
} ) ;
let newLabels = [ ] ;
let newLabels = [ ] ;
if ( issue . data . labels . length > 0 ) {
if ( issue . data . labels . length > 0 ) {
newLabels = issue . data . labels . map ( ( { name } ) => name ) . filter ( name => ! dealStringToArr ( removeLables ) . includes ( name ) ) ;
newLabels = issue . data . labels
. map ( ( { name } ) => name )
. filter ( name => ! dealStringToArr ( removeLables ) . includes ( name ) ) ;
}
}
if ( duplicateLabels ) {
if ( duplicateLabels ) {
newLabels = [ ... newLabels , ... dealStringToArr ( duplicateLabels ) ] ;
newLabels = [ ... newLabels , ... dealStringToArr ( duplicateLabels ) ] ;
@@ -8071,32 +8071,34 @@ async function doMarkDuplicate (owner, repo, labels) {
await doCloseIssue ( owner , repo , issueNumber ) ;
await doCloseIssue ( owner , repo , issueNumber ) ;
}
}
} else {
} else {
core . info ( ` This comment body should start whith 'duplicate-command' or 'Duplicate of' and not include '?' ` ) ;
core . info (
` This comment body should start whith 'duplicate-command' or 'Duplicate of' and not include '?' ` ,
) ;
}
}
} else {
} else {
core . info ( ` This actions only support on 'issue_comment' created or edited! ` ) ;
core . info ( ` This actions only support on 'issue_comment' created or edited! ` ) ;
}
}
} ;
}
async function doOpenIssue ( owner , repo , issueNumber ) {
async function doOpenIssue ( owner , repo , issueNumber ) {
await octokit . issues . update ( {
await octokit . issues . update ( {
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber ,
issue _number : issueNumber ,
state : 'open'
state : 'open' ,
} ) ;
} ) ;
core . info ( ` Actions: [open-issue][ ${ issueNumber } ] success! ` ) ;
core . info ( ` Actions: [open-issue][ ${ issueNumber } ] success! ` ) ;
} ;
}
async function doRemoveAssignees ( owner , repo , issueNumber , assignees ) {
async function doRemoveAssignees ( owner , repo , issueNumber , assignees ) {
await octokit . issues . removeAssignees ( {
await octokit . issues . removeAssignees ( {
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber ,
issue _number : issueNumber ,
assignees : dealStringToArr ( assignees )
assignees : dealStringToArr ( assignees ) ,
} ) ;
} ) ;
core . info ( ` Actions: [remove-assignees][ ${ assignees } ] success! ` ) ;
core . info ( ` Actions: [remove-assignees][ ${ assignees } ] success! ` ) ;
} ;
}
async function doRemoveLabels ( owner , repo , issueNumber , labels ) {
async function doRemoveLabels ( owner , repo , issueNumber , labels ) {
const dealLabels = dealStringToArr ( labels ) ;
const dealLabels = dealStringToArr ( labels ) ;
@@ -8110,7 +8112,7 @@ async function doRemoveLabels (owner, repo, issueNumber, labels) {
core . info ( ` Actions: [remove-labels-foreach][ ${ label } ] success! ` ) ;
core . info ( ` Actions: [remove-labels-foreach][ ${ label } ] success! ` ) ;
}
}
core . info ( ` Actions: [remove-labels][ ${ labels } ] success! ` ) ;
core . info ( ` Actions: [remove-labels][ ${ labels } ] success! ` ) ;
} ;
}
async function doSetLabels ( owner , repo , issueNumber , labels ) {
async function doSetLabels ( owner , repo , issueNumber , labels ) {
// 概率性出现问题: https://github.com/octokit/rest.js/issues/1982, 规避 setLabels
// 概率性出现问题: https://github.com/octokit/rest.js/issues/1982, 规避 setLabels
@@ -8124,7 +8126,7 @@ async function doSetLabels (owner, repo, issueNumber, labels) {
const issue = await octokit . issues . get ( {
const issue = await octokit . issues . get ( {
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber
issue _number : issueNumber ,
} ) ;
} ) ;
const baseLabels = issue . data . labels . map ( ( { name } ) => name ) ;
const baseLabels = issue . data . labels . map ( ( { name } ) => name ) ;
const removeLabels = baseLabels . filter ( name => ! dealStringToArr ( labels ) . includes ( name ) ) ;
const removeLabels = baseLabels . filter ( name => ! dealStringToArr ( labels ) . includes ( name ) ) ;
@@ -8142,7 +8144,7 @@ async function doSetLabels (owner, repo, issueNumber, labels) {
core . info ( ` Actions: [set-labels][ ${ labels } ] success! ` ) ;
core . info ( ` Actions: [set-labels][ ${ labels } ] success! ` ) ;
}
}
} ;
}
async function doUnlockIssue ( owner , repo , issueNumber ) {
async function doUnlockIssue ( owner , repo , issueNumber ) {
await octokit . issues . unlock ( {
await octokit . issues . unlock ( {
@@ -8151,30 +8153,23 @@ async function doUnlockIssue (owner, repo, issueNumber) {
issue _number : issueNumber ,
issue _number : issueNumber ,
} ) ;
} ) ;
core . info ( ` Actions: [unlock-issue][ ${ issueNumber } ] success! ` ) ;
core . info ( ` Actions: [unlock-issue][ ${ issueNumber } ] success! ` ) ;
} ;
}
async function doUpdateComment (
async function doUpdateComment (owner , repo , commentId , body , updateMode , ifUpdateBody ) {
owner ,
repo ,
commentId ,
body ,
updateMode ,
ifUpdateBody ,
) {
const comment = await octokit . issues . getComment ( {
const comment = await octokit . issues . getComment ( {
owner ,
owner ,
repo ,
repo ,
comment _id : commentId
comment _id : commentId ,
} )
} ) ;
const comment _body = comment . data . body ;
const comment _body = comment . data . body ;
let params = {
let params = {
owner ,
owner ,
repo ,
repo ,
comment _id : commentId
comment _id : commentId ,
} ;
} ;
if ( core . getInput ( " body" ) || ifUpdateBody ) {
if ( core . getInput ( ' body' ) || ifUpdateBody ) {
if ( updateMode === 'append' ) {
if ( updateMode === 'append' ) {
params . body = ` ${ comment _body } \n ${ body } ` ;
params . body = ` ${ comment _body } \n ${ body } ` ;
} else {
} else {
@@ -8188,7 +8183,7 @@ async function doUpdateComment (
if ( contents ) {
if ( contents ) {
await doCreateCommentContent ( owner , repo , commentId , dealStringToArr ( contents ) ) ;
await doCreateCommentContent ( owner , repo , commentId , dealStringToArr ( contents ) ) ;
}
}
} ;
}
async function doUpdateIssue (
async function doUpdateIssue (
owner ,
owner ,
@@ -8199,13 +8194,13 @@ async function doUpdateIssue (
body ,
body ,
updateMode ,
updateMode ,
assignees ,
assignees ,
labels
labels ,
) {
) {
const issue = await octokit . issues . get ( {
const issue = await octokit . issues . get ( {
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber
issue _number : issueNumber ,
} )
} ) ;
const issue _body = issue . data . body ;
const issue _body = issue . data . body ;
const issue _title = issue . data . title ;
const issue _title = issue . data . title ;
@@ -8227,13 +8222,13 @@ async function doUpdateIssue (
owner ,
owner ,
repo ,
repo ,
issue _number : issueNumber ,
issue _number : issueNumber ,
state
state ,
} ;
} ;
params . title = core . getInput ( " title" ) ? title : issue _title ;
params . title = core . getInput ( ' title' ) ? title : issue _title ;
let next _body ;
let next _body ;
if ( core . getInput ( " body" ) ) {
if ( core . getInput ( ' body' ) ) {
if ( updateMode === 'append' ) {
if ( updateMode === 'append' ) {
next _body = ` ${ issue _body } \n ${ body } ` ;
next _body = ` ${ issue _body } \n ${ body } ` ;
} else {
} else {
@@ -8253,21 +8248,21 @@ async function doUpdateIssue (
if ( contents ) {
if ( contents ) {
await doCreateIssueContent ( owner , repo , issueNumber , contents ) ;
await doCreateIssueContent ( owner , repo , issueNumber , contents ) ;
}
}
} ;
}
async function doWelcome ( owner , repo , assignees , labels , body ) {
async function doWelcome ( owner , repo , assignees , labels , body ) {
const context = github . context ;
const context = github . context ;
const isIssue = ! ! context . payload . issue ;
const isIssue = ! ! context . payload . issue ;
const issueContents = core . getInput ( " issue-contents" ) ;
const issueContents = core . getInput ( ' issue-contents' ) ;
if ( ! isIssue ) {
if ( ! isIssue ) {
core . setFailed ( " The event that triggered this action must be a issue. Error!" ) ;
core . setFailed ( ' The event that triggered this action must be a issue. Error!' ) ;
} else {
} else {
const auth = context . payload . sender . login ;
const auth = context . payload . sender . login ;
core . info ( ` Actions: [welcome: auth=][ ${ auth } ] ` ) ;
core . info ( ` Actions: [welcome: auth=][ ${ auth } ] ` ) ;
const issueNumber = context . issue . number ;
const issueNumber = context . issue . number ;
const issues = await doQueryIssues ( owner , repo , false , 'all' , auth ) ;
const issues = await doQueryIssues ( owner , repo , false , 'all' , auth ) ;
if ( issues . length == 0 || ( issues . length == 1 && issues [ 0 ] . number == issueNumber ) ) {
if ( issues . length == 0 || ( issues . length == 1 && issues [ 0 ] . number == issueNumber ) ) {
if ( core . getInput ( " body" ) ) {
if ( core . getInput ( ' body' ) ) {
await doCreateComment ( owner , repo , issueNumber , body ) ;
await doCreateComment ( owner , repo , issueNumber , body ) ;
} else {
} else {
core . info ( ` Actions: [welcome] no body! ` ) ;
core . info ( ` Actions: [welcome] no body! ` ) ;
@@ -8288,17 +8283,17 @@ async function doWelcome (owner, repo, assignees, labels, body) {
core . info ( ` Actions: [welcome][ ${ auth } ] is not first time! ` ) ;
core . info ( ` Actions: [welcome][ ${ auth } ] is not first time! ` ) ;
}
}
}
}
} ;
}
// **************************************************************************
// **************************************************************************
function testContent ( con ) {
function testContent ( con ) {
if ( ALLREACTIONS . includes ( con ) ) {
if ( ALLREACTIONS . includes ( con ) ) {
return true ;
return true ;
} else {
} else {
core . setFailed ( " This actions not supported!" ) ;
core . setFailed ( ' This actions not supported!' ) ;
return false ;
return false ;
}
}
} ;
}
// **************************************************************************
// **************************************************************************
module . exports = {
module . exports = {
@@ -8398,24 +8393,24 @@ async function main() {
const issueNumber = core . getInput ( 'issue-number' ) ;
const issueNumber = core . getInput ( 'issue-number' ) ;
const commentId = core . getInput ( 'comment-id' ) ;
const commentId = core . getInput ( 'comment-id' ) ;
const defaultBody = ` Currently at ${ owner } / ${ repo } . And this is default comment. `
const defaultBody = ` Currently at ${ owner } / ${ repo } . And this is default comment. ` ;
const body = core . getInput ( " body" ) || defaultBody ;
const body = core . getInput ( ' body' ) || defaultBody ;
const defaultTitle = ` Default Title ` ;
const defaultTitle = ` Default Title ` ;
const title = core . getInput ( " title" ) || defaultTitle ;
const title = core . getInput ( ' title' ) || defaultTitle ;
const assignees = core . getInput ( " assignees" ) ;
const assignees = core . getInput ( ' assignees' ) ;
const labels = core . getInput ( " labels" ) ;
const labels = core . getInput ( ' labels' ) ;
const state = core . getInput ( " state" ) || 'open' ;
const state = core . getInput ( ' state' ) || 'open' ;
let updateMode = core . getInput ( " update-mode" ) ;
let updateMode = core . getInput ( ' update-mode' ) ;
if ( updateMode !== 'append' ) {
if ( updateMode !== 'append' ) {
updateMode = 'replace' ;
updateMode = 'replace' ;
}
}
// actions
// actions
const actions = core . getInput ( " actions" , { required : true } ) ;
const actions = core . getInput ( ' actions' , { required : true } ) ;
const actionsArr = actions . split ( ',' ) ;
const actionsArr = actions . split ( ',' ) ;
actionsArr . forEach ( item => {
actionsArr . forEach ( item => {
@@ -8426,9 +8421,9 @@ async function main() {
if ( ALLACTIONS . includes ( action ) ) {
if ( ALLACTIONS . includes ( action ) ) {
choseActions ( action ) ;
choseActions ( action ) ;
} else {
} else {
core . setFailed ( " This actions not supported!" ) ;
core . setFailed ( ' This actions not supported!' ) ;
}
}
}
} ;
async function choseActions ( action ) {
async function choseActions ( action ) {
switch ( action ) {
switch ( action ) {
@@ -8473,13 +8468,7 @@ async function main() {
await doUnlockIssue ( owner , repo , issueNumber ) ;
await doUnlockIssue ( owner , repo , issueNumber ) ;
break ;
break ;
case 'update-comment' :
case 'update-comment' :
await doUpdateComment (
await doUpdateComment ( owner , repo , commentId , body , updateMode ) ;
owner ,
repo ,
commentId ,
body ,
updateMode
) ;
break ;
break ;
case 'update-issue' :
case 'update-issue' :
await doUpdateIssue (
await doUpdateIssue (
@@ -8491,70 +8480,38 @@ async function main() {
body ,
body ,
updateMode ,
updateMode ,
assignees ,
assignees ,
labels
labels ,
) ;
) ;
break ;
break ;
case 'welcome' :
case 'welcome' :
await doWelcome (
await doWelcome ( owner , repo , assignees , labels , body ) ;
owner ,
repo ,
assignees ,
labels ,
body
) ;
break ;
break ;
// advanced
// advanced
case 'check-inactive' :
case 'check-inactive' :
await doCheckInactive (
await doCheckInactive ( owner , repo , labels ) ;
owner ,
repo ,
labels
)
break ;
break ;
case 'check-issue' :
case 'check-issue' :
await doCheckIssue (
await doCheckIssue ( owner , repo , issueNumber ) ;
owner ,
repo ,
issueNumber
) ;
break ;
break ;
case 'close-issues' :
case 'close-issues' :
await doCloseIssues (
await doCloseIssues ( owner , repo , labels ) ;
owner ,
repo ,
labels
)
break ;
break ;
case 'find-comments' :
case 'find-comments' :
await doFindComments (
await doFindComments ( owner , repo , issueNumber ) ;
owner ,
repo ,
issueNumber
) ;
break ;
break ;
case 'lock-issues' :
case 'lock-issues' :
await doLockIssues (
await doLockIssues ( owner , repo , labels ) ;
owner ,
repo ,
labels
) ;
break ;
break ;
case 'month-statistics' :
case 'month-statistics' :
await doMonthStatistics (
await doMonthStatistics ( owner , repo , labels , assignees ) ;
owner ,
repo ,
labels ,
assignees
) ;
break ;
break ;
// default
// default
default :
default :
break ;
break ;
}
}
} ;
}
}
catch ( error ) {
} catch ( error ) {
core . setFailed ( error . message ) ;
core . setFailed ( error . message ) ;
}
}
}
}
@@ -8572,9 +8529,7 @@ __webpack_require__(2437).config();
const core = _ _webpack _require _ _ ( 2186 ) ;
const core = _ _webpack _require _ _ ( 2186 ) ;
const { Octokit } = _ _webpack _require _ _ ( 5375 ) ;
const { Octokit } = _ _webpack _require _ _ ( 5375 ) ;
const {
const { getPreMonth } = _ _webpack _require _ _ ( 6254 ) ;
getPreMonth
} = _ _webpack _require _ _ ( 6254 ) ;
// **************************************************************************
// **************************************************************************
var dayjs = _ _webpack _require _ _ ( 7401 ) ;
var dayjs = _ _webpack _require _ _ ( 7401 ) ;
@@ -8589,14 +8544,14 @@ const octokit = new Octokit({ auth: `token ${token}` });
const perPage = 100 ;
const perPage = 100 ;
const issueCreator = core . getInput ( " issue-creator" ) ;
const issueCreator = core . getInput ( ' issue-creator' ) ;
const issueAssignee = core . getInput ( 'issue-assignee' ) ;
const issueAssignee = core . getInput ( 'issue-assignee' ) ;
const issueMentioned = core . getInput ( 'issue-mentioned' ) ;
const issueMentioned = core . getInput ( 'issue-mentioned' ) ;
const bodyIncludes = core . getInput ( 'body-includes' ) ;
const bodyIncludes = core . getInput ( 'body-includes' ) ;
const titleIncludes = core . getInput ( 'title-includes' ) ;
const titleIncludes = core . getInput ( 'title-includes' ) ;
const inactiveDay = core . getInput ( " inactive-day" ) ;
const inactiveDay = core . getInput ( ' inactive-day' ) ;
// **************************************************************************
// **************************************************************************
async function doQueryIssues ( owner , repo , labels , state , creator ) {
async function doQueryIssues ( owner , repo , labels , state , creator ) {
@@ -8606,9 +8561,9 @@ async function doQueryIssues (owner, repo, labels, state, creator) {
state ,
state ,
} ;
} ;
issueCreator ? params . creator = issueCreator : null ;
issueCreator ? ( params . creator = issueCreator ) : null ;
issueAssignee ? params . assignee = issueAssignee : null ;
issueAssignee ? ( params . assignee = issueAssignee ) : null ;
issueMentioned ? params . mentioned = issueMentioned : null ;
issueMentioned ? ( params . mentioned = issueMentioned ) : null ;
if ( labels ) {
if ( labels ) {
params . labels = labels ;
params . labels = labels ;
@@ -8643,24 +8598,24 @@ async function doQueryIssues (owner, repo, labels, state, creator) {
issueNumbers . push ( iss . number ) ;
issueNumbers . push ( iss . number ) ;
}
}
}
}
} )
} ) ;
core . info ( ` Actions: [query-issues]: [ ${ JSON . stringify ( issueNumbers ) } ]! ` ) ;
core . info ( ` Actions: [query-issues]: [ ${ JSON . stringify ( issueNumbers ) } ]! ` ) ;
}
}
return issues ;
return issues ;
} ;
}
async function getIssues ( params , page = 1 ) {
async function getIssues ( params , page = 1 ) {
let { data : issues } = await octokit . issues . listForRepo ( {
let { data : issues } = await octokit . issues . listForRepo ( {
... params ,
... params ,
per _page : perPage ,
per _page : perPage ,
page
page ,
} ) ;
} ) ;
if ( issues . length >= perPage ) {
if ( issues . length >= perPage ) {
issues = issues . concat ( await getIssues ( params , page + 1 ) ) ;
issues = issues . concat ( await getIssues ( params , page + 1 ) ) ;
}
}
return issues ;
return issues ;
} ;
}
async function getIssuesInMonth ( owner , repo , thisMonth , page = 1 ) {
async function getIssuesInMonth ( owner , repo , thisMonth , page = 1 ) {
const month = getPreMonth ( thisMonth ) ;
const month = getPreMonth ( thisMonth ) ;
@@ -8669,21 +8624,25 @@ async function getIssuesInMonth (owner, repo, thisMonth, page = 1) {
repo ,
repo ,
state : 'all' ,
state : 'all' ,
per _page : perPage ,
per _page : perPage ,
page
page ,
} ) ;
} ) ;
issues = issues . filter ( i => {
issues = issues . filter ( i => {
return i . pull _request === undefined
return i . pull _request === undefined ;
} ) ;
} ) ;
if ( issues . length && getCreatedMonth ( issues [ issues . length - 1 ] . created _at ) >= month ) {
if ( issues . length && getCreatedMonth ( issues [ issues . length - 1 ] . created _at ) >= month ) {
issues = issues . concat ( await getIssuesInMonth ( owner , repo , thisMonth , page + 1 ) ) ;
issues = issues . concat ( await getIssuesInMonth ( owner , repo , thisMonth , page + 1 ) ) ;
}
}
return issues ;
return issues ;
} ;
}
// **************************************************************************
// **************************************************************************
function getCreatedMonth ( d ) {
function getCreatedMonth ( d ) {
return dayjs ( d ) . utc ( ) . month ( ) + 1 ;
return (
} ;
dayjs ( d )
. utc ( )
. month ( ) + 1
) ;
}
// **************************************************************************
// **************************************************************************
module . exports = {
module . exports = {
@@ -8711,12 +8670,12 @@ function dealStringToArr (para) {
const paraArr = para . split ( ',' ) ;
const paraArr = para . split ( ',' ) ;
paraArr . forEach ( it => {
paraArr . forEach ( it => {
if ( it . trim ( ) ) {
if ( it . trim ( ) ) {
arr . push ( it . trim ( ) )
arr . push ( it . trim ( ) ) ;
}
}
} )
} ) ;
}
}
return arr ;
return arr ;
} ;
}
function dealRandomAssignees ( assignees , randomTo ) {
function dealRandomAssignees ( assignees , randomTo ) {
let arr = dealStringToArr ( assignees ) ;
let arr = dealStringToArr ( assignees ) ;
@@ -8724,11 +8683,11 @@ function dealRandomAssignees (assignees, randomTo) {
arr = sampleSize ( arr , randomTo ) ;
arr = sampleSize ( arr , randomTo ) ;
}
}
return arr ;
return arr ;
} ;
}
function matchKeyword ( content , keywords ) {
function matchKeyword ( content , keywords ) {
return keywords . find ( item => content . toLowerCase ( ) . includes ( item ) ) ;
return keywords . find ( item => content . toLowerCase ( ) . includes ( item ) ) ;
} ;
}
function testDuplicate ( body ) {
function testDuplicate ( body ) {
if ( ! body || ! body . startsWith ( 'Duplicate of' ) ) {
if ( ! body || ! body . startsWith ( 'Duplicate of' ) ) {
@@ -8741,11 +8700,11 @@ function testDuplicate(body) {
} else {
} else {
return false ;
return false ;
}
}
} ;
}
function getPreMonth ( m ) {
function getPreMonth ( m ) {
return m == 1 ? 12 : m - 1 ;
return m == 1 ? 12 : m - 1 ;
} ;
}
module . exports = {
module . exports = {
dealStringToArr ,
dealStringToArr ,