diff --git a/README.md b/README.md index f2e76c8..67c69ac 100644 --- a/README.md +++ b/README.md @@ -792,6 +792,7 @@ jobs: | body-includes | Body filtering | string | ✖ | | title-includes | Title filtering | string | ✖ | | inactive-day | Inactive days filtering | number | ✖ | +| inactive-day | Detect inactive mode, default `issue`, optional `comment`, which is the last comment update time | string | ✖ | | inactive-label | The label name adding | string | ✖ | | exclude-labels | Exclude labels filtering | string | ✖ | diff --git a/README.zh-CN.md b/README.zh-CN.md index 1809c89..932820b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -796,6 +796,7 @@ jobs: | body-includes | 包含内容筛选 | string | ✖ | | title-includes | 包含标题筛选 | string | ✖ | | inactive-day | 非活跃天数筛选 | number | ✖ | +| inactive-day | 检测不活跃的模式,默认 `issue`,可选 `comment`,即为最后一个评论更新时间 | string | ✖ | | inactive-label | 新增标签名称 | string | ✖ | | exclude-labels | 排除标签筛选 | string | ✖ | diff --git a/action.yml b/action.yml index 60bd27a..efc3bce 100644 --- a/action.yml +++ b/action.yml @@ -75,6 +75,8 @@ inputs: description: 'Query use' inactive-day: description: 'Query use' + inactive-mode: + description: 'Inactive mode' lock-reason: description: 'The reason lock issue' inactive-label: diff --git a/package.json b/package.json index 829ec67..5fcbe9e 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "lint": "eslint src/*.ts src/*/*.ts", "lint-fix": "eslint src/*.ts src/*/*.ts --fix", "lint-up": "npm run format && npm run lint-fix", + "ci:fix": "npm run lint-up", "lint-all": "npm run format-check && npm run lint", "check-commit": "node ./scripts/check-commit.js", "tag": "node ./scripts/tag.js", diff --git a/src/helper/advanced.ts b/src/helper/advanced.ts index 591c5b9..9f53066 100644 --- a/src/helper/advanced.ts +++ b/src/helper/advanced.ts @@ -59,7 +59,7 @@ export async function doQueryIssues( const titleIncludes = core.getInput('title-includes'); const excludeLabelsArr = dealStringToArr(excludeLabels); - issuesList.forEach(issue => { + issuesList.forEach(async issue => { const bodyCheck = bodyIncludes ? issue.body.includes(bodyIncludes) : true; const titleCheck = titleIncludes ? issue.title.includes(titleIncludes) : true; /** @@ -84,8 +84,17 @@ export async function doQueryIssues( dayjs.extend(isSameOrBefore); const lastTime = dayjs.utc().subtract(+inactiveDay, 'day'); - const updateTime = dayjs.utc(issue.updated_at); - if (updateTime.isSameOrBefore(lastTime)) { + + const inactiveMode = core.getInput('inactive-mode') || 'issue'; + let updateTime = dayjs.utc(issue.updated_at); + if (inactiveMode === 'comment') { + ICE.setIssueNumber(issue.number); + const comments = await ICE.listComments(); + if (comments.length) { + updateTime = dayjs.utc(comments[comments.length - 1].updated_at); + } + } + if (updateTime && updateTime.isSameOrBefore(lastTime)) { issues.push(issue); issueNumbers.push(issue.number); }