Skip to content

Commit

Permalink
feat: support comment update 4 check-inactive
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed Jul 19, 2023
1 parent 0d51d36 commit 31e23a0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | ✖ |

Expand Down
1 change: 1 addition & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | ✖ |

Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 12 additions & 3 deletions src/helper/advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand All @@ -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);
}
Expand Down

0 comments on commit 31e23a0

Please sign in to comment.