Compare commits

...

8 Commits
v1.3 ... v1.6

Author SHA1 Message Date
xrkffgg
44240d2ab3 docs: update changelog 2020-12-30 15:25:03 +08:00
xrkffgg
da1f8da3d4 perf: optimize duplicate (#24)
* perf: optimize mark duplicate

* add

* add

* add

* add

* add
2020-12-30 15:17:26 +08:00
xrkffgg
1cf278b531 Rename changelog.md to CHANGELOG.md 2020-12-30 13:52:03 +08:00
xrkffgg
09b55c2859 chore: update name 2020-12-30 13:51:10 +08:00
xrkffgg
c81901f651 feat: add mark-duplicate (#23)
* feat: add mark-duplicate

* add

* add

* add

* add

* add

* add

* add

* change

* update
2020-12-30 13:48:38 +08:00
xrkffgg
a2273a4c3b Create check-dist.yml 2020-12-30 09:22:40 +08:00
xrkffgg
3cd24426bf fix: check inactive (#22)
* fix: check inactive

* add
2020-12-29 13:51:21 +08:00
xrkffgg
f3809e03c1 docs: update changelog link 2020-12-29 09:56:53 +08:00
18 changed files with 474 additions and 71 deletions

27
.github/workflows/check-dist.yml vendored Normal file
View File

@@ -0,0 +1,27 @@
name: Update dist
on:
push:
branches: [ main ]
jobs:
check-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: install
run: yarn
- name: package
run: yarn package
- name: Commit and push if changed
run: |-
git diff
git config --global user.email "xrkffgg@vip.qq.com"
git config --global user.name "xrkffgg"
git pull
git add -A
git commit -m "🤖 auto: updated dist" || exit 0
git push

View File

@@ -1,3 +1,21 @@
## v1.6
`2020.12.30`
- perf: optimize duplicate. [#24](https://github.com/actions-cool/issues-helper/pull/24)
## v1.5
`2020.12.30`
- feat: add `mark-duplicate`. [#23](https://github.com/actions-cool/issues-helper/pull/23)
## v1.4
`2020.12.29`
- fix: perfect `inactive-day` check. [#22](https://github.com/actions-cool/issues-helper/pull/22)
## v1.3
`2020.12.28`

View File

@@ -12,7 +12,7 @@
A GitHub Action that easily helps you automatically manage issues
[Online documentation](https://actions-cool.github.io/issues-helper) | [Changelog](https://actions-cool.github.io/issues-helper/en-US/changelog)
[Online documentation](https://actions-cool.github.io/issues-helper) | [Changelog](https://github.com/actions-cool/issues-helper/blob/main/CHANGELOG.md)
## 😎 Why use GitHub Action?
@@ -34,6 +34,7 @@ When the following list does not have the features you want, you can submit it i
- [`create-issue`](#create-issue)
- [`delete-comment`](#delete-comment)
- [`lock-issue`](#lock-issue)
- [`mark-duplicate`](#mark-duplicate)
- [`open-issue`](#open-issue)
- [`remove-assignees`](#remove-assignees)
- [`remove-labels`](#remove-labels)
@@ -294,6 +295,43 @@ jobs:
⏫ [Back to list](#List)
#### `mark-duplicate`
Quickly mark duplicate questions, only for issue new comments.
```yml
name: Issue Mark Duplicate
on:
issue_comment:
types: [created]
jobs:
mark-duplicate:
runs-on: ubuntu-latest
steps:
- name: mark-duplicate
uses: actions-cool/issues-helper@v1.5
with:
actions: 'mark-duplicate'
token: ${{ secrets.GITHUB_TOKEN }}
```
| Param | Desc | Type | Required | Version |
| -- | -- | -- | -- | -- |
| actions | Action type | string | ✔ | v1.5 |
| token | [Token explain](#token) | string | ✔ | v1.5 |
| duplicate-command | Simple commands can be set, such as: `/d` | string | ✖ | v1.6 |
| duplicate-labels | Add additional labels to this issue | string | ✖ | v1.5 |
| labels | Replace the labels of the issue | string | ✖ | v1.5 |
| contents | Add [reaction](#reactions-types) for this comment | string | ✖ | v1.5 |
| close-issue | Whether to close the issue at the same time | string | ✖ | v1.6 |
- `duplicate-command`: When setting concise commands, while still supporting the original `Duplicate of`
- `close-issue`: Both `true` or `'true'` can take effect
⏫ [Back to list](#List)
#### `open-issue`
Open the specified issue.
@@ -558,6 +596,7 @@ jobs:
| actions | Action type | string | ✔ | v1 |
| token | [Token explain](#token) | string | ✔ | v1 |
| body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 |
| contents | Add [reaction](#reactions-types) for this comment | string | ✖ | v1 |
| labels | Labels filtering | string | ✖ | v1.1 |
| issue-state | State filtering | string | ✖ | v1 |
| issue-assignee | Assignee filtering | string | ✖ | v1 |
@@ -565,7 +604,7 @@ jobs:
| issue-mentioned | Mentioned filtering | string | ✖ | v1 |
| body-includes | Body filtering | string | ✖ | v1 |
| title-includes | Title filtering | string | ✖ | v1 |
| inactive-day | Inactive days filtering | number | ✖ | v1.2 |
| inactive-day | Inactive days filtering | number | ✖ | v1.4 |
| inactive-label | The label name adding | string | ✖ | v1 |
- `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all
@@ -650,13 +689,14 @@ jobs:
| actions | Action type | string | ✔ | v1 |
| token | [Token explain](#token) | string | ✔ | v1 |
| body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 |
| contents | Add [reaction](#reactions-types) for this comment | string | ✖ | v1 |
| labels | Labels filtering | string | ✖ | v1.1 |
| issue-assignee | Assignee filtering | string | ✖ | v1 |
| issue-creator | Creator filtering | string | ✖ | v1 |
| issue-mentioned | Mentioned filtering | string | ✖ | v1 |
| body-includes | Body filtering | string | ✖ | v1 |
| title-includes | Title filtering | string | ✖ | v1 |
| inactive-day | Inactive days filtering | number | ✖ | v1.2 |
| inactive-day | Inactive days filtering | number | ✖ | v1.4 |
- `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all
- `issue-assignee`: Multiplayer is not supported. If you do not enter or enter *, all will be searched. Entering `none` will query issues for which the specified person is not added
@@ -731,6 +771,7 @@ jobs:
| actions | Action type | string | ✔ | v1 |
| token | [Token explain](#token) | string | ✔ | v1 |
| body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 |
| contents | Add [reaction](#reactions-types) for this comment | string | ✖ | v1 |
| labels | Labels filtering | string | ✖ | v1.1 |
| issue-state | State filtering | string | ✖ | v1 |
| issue-assignee | Assignee filtering | string | ✖ | v1 |
@@ -738,7 +779,7 @@ jobs:
| issue-mentioned | Mentioned filtering | string | ✖ | v1 |
| body-includes | Body filtering | string | ✖ | v1 |
| title-includes | Title filtering | string | ✖ | v1 |
| inactive-day | Inactive days filtering | number | ✖ | v1.2 |
| inactive-day | Inactive days filtering | number | ✖ | v1.4 |
- `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all
- `issue-state`: The default is `all`. Optional value `open` `closed`, when these 2 items are not, both are `all`
@@ -888,6 +929,25 @@ Click the `···` icon in the upper right corner of a comment, select `Copy lin
⏫ [Back to list](#List)
## ✨ Version
- Version rules
- Use two-level semantic version, such as v1, v1.1, v2, v2.1
- v1 represents the initial version
- The fixes and additions to the v1 version will be released to the v1.1 version
- When the released v1.x runs stable for a certain period of time, release the advanced v2 version
- The parameters in the API must use the largest version and above
- Version selection
- It is recommended to use the latest releases version. It can be seen in [releases](https://github.com/actions-cool/issues-helper/releases)
- You can also refer to the update log below to select the version
- It also supports the direct use of branch versions. Such as:
```yml
- name: Issues Helper
uses: actions-cool/issues-helper@main
```
## Actions Template
- You can directly use this [GitHub Actions workflow template](https://github.com/actions-cool/.github) repositorie template
@@ -929,19 +989,19 @@ At the same time, if you have any questions during use, you can also ask and inq
</td>
</tr>
<tr>
<td align="center" wdith="160">
<td align="center" width="160">
<strong>ant-design</strong>
</td>
<td align="center" wdith="160">
<td align="center" width="160">
<strong>ant-design-vue</strong>
</td>
<td align="center" wdith="160">
<td align="center" width="160">
<strong>dumi</strong>
</td>
<td align="center" wdith="160">
<td align="center" width="160">
<strong>umi</strong>
</td>
<td align="center" wdith="160">
<td align="center" width="160">
<strong>vue-request</strong>
</td>
</tr>

View File

@@ -12,7 +12,7 @@
一个轻松帮你自动管理 issues 的 GitHub Action
[在线文档](https://actions-cool.github.io/issues-helper/) | [更新日志](https://actions-cool.github.io/issues-helper/changelog)
[在线文档](https://actions-cool.github.io/issues-helper/) | [更新日志](https://github.com/actions-cool/issues-helper/blob/main/CHANGELOG.md)
## 😎 为什么用 GitHub Action
@@ -34,6 +34,7 @@
- [`create-issue`](#create-issue)
- [`delete-comment`](#delete-comment)
- [`lock-issue`](#lock-issue)
- [`mark-duplicate`](#mark-duplicate)
- [`open-issue`](#open-issue)
- [`remove-assignees`](#remove-assignees)
- [`remove-labels`](#remove-labels)
@@ -294,6 +295,43 @@ jobs:
⏫ [返回列表](#列-表)
#### `mark-duplicate`
快捷标记重复问题,仅作用于 issue 新增评论。
```yml
name: Issue Mark Duplicate
on:
issue_comment:
types: [created]
jobs:
mark-duplicate:
runs-on: ubuntu-latest
steps:
- name: mark-duplicate
uses: actions-cool/issues-helper@v1.5
with:
actions: 'mark-duplicate'
token: ${{ secrets.GITHUB_TOKEN }}
```
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ | v1.5 |
| token | [token 说明](#token) | string | ✔ | v1.5 |
| duplicate-command | 可设置简洁命令,如:`/d` | string | ✖ | v1.6 |
| duplicate-labels | 为该 issue 额外增加 labels | string | ✖ | v1.5 |
| labels | 替换该 issue 的 labels | string | ✖ | v1.5 |
| contents | 为该评论的增加 [reaction](#reactions-types) | string | ✖ | v1.5 |
| close-issue | 是否同时关闭该 issue | string | ✖ | v1.6 |
- `duplicate-command`:当设置简洁命令时,同时仍支持原有 `Duplicate of`
- `close-issue``true``'true'` 均可生效
⏫ [返回列表](#列-表)
#### `open-issue`
打开指定 issue。
@@ -556,6 +594,7 @@ jobs:
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 |
| contents | 为该评论增加 [reaction](#reactions-types) | string | ✖ | v1 |
| labels | 标签筛选 | string | ✖ | v1.1 |
| issue-state | 状态筛选 | string | ✖ | v1 |
| issue-assignee | 指定人筛选 | string | ✖ | v1 |
@@ -563,7 +602,7 @@ jobs:
| issue-mentioned | 提及人筛选 | string | ✖ | v1 |
| body-includes | 包含内容筛选 | string | ✖ | v1 |
| title-includes | 包含标题筛选 | string | ✖ | v1 |
| inactive-day | 非活跃天数筛选 | number | ✖ | v1.2 |
| inactive-day | 非活跃天数筛选 | number | ✖ | v1.4 |
| inactive-label | 新增标签名称 | string | ✖ | v1 |
- `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有
@@ -644,13 +683,14 @@ jobs:
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 |
| contents | 为该评论增加 [reaction](#reactions-types) | string | ✖ | v1 |
| labels | 标签筛选 | string | ✖ | v1.1 |
| issue-assignee | 指定人筛选 | string | ✖ | v1 |
| issue-creator | 创建人筛选 | string | ✖ | v1 |
| issue-mentioned | 提及人筛选 | string | ✖ | v1 |
| body-includes | 包含内容筛选 | string | ✖ | v1 |
| title-includes | 包含标题筛选 | string | ✖ | v1 |
| inactive-day | 非活跃天数筛选 | number | ✖ | v1.2 |
| inactive-day | 非活跃天数筛选 | number | ✖ | v1.4 |
- `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有
- `issue-assignee`:不支持多人。不填或输入 * 时,查询所有。输入 `none` 会查询未添加指定人的 issues
@@ -725,6 +765,7 @@ jobs:
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](#token) | string | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 |
| contents | 为该评论增加 [reaction](#reactions-types) | string | ✖ | v1 |
| labels | 标签筛选 | string | ✖ | v1.1 |
| issue-state | 状态筛选 | string | ✖ | v1 |
| issue-assignee | 指定人筛选 | string | ✖ | v1 |
@@ -732,7 +773,7 @@ jobs:
| issue-mentioned | 提及人筛选 | string | ✖ | v1 |
| body-includes | 包含内容筛选 | string | ✖ | v1 |
| title-includes | 包含标题筛选 | string | ✖ | v1 |
| inactive-day | 非活跃天数筛选 | number | ✖ | v1.2 |
| inactive-day | 非活跃天数筛选 | number | ✖ | v1.4 |
- `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有
- `issue-state`:默认为 `all`。可选值 `open` `closed`,非这 2 项时,均为 `all`
@@ -883,6 +924,25 @@ x2 + y2
⏫ [返回列表](#列-表)
## ✨ 版本
- 版本规则
- 采用两级语义化版本如v1、v1.1、v2、v2.1
- v1 表示初始版本
- 对 v1 版本的修复和新增会发布到 v1.1 版本
- 当发布的 v1.x 运行一定时间稳定后,发布进阶 v2 版本
- API 中参数需使用其中最大及以上版本
- 版本选择
- 建议采用最新 releases 版本。可在 [releases](https://github.com/actions-cool/issues-helper/releases) 看到
- 同时也可参照下面的更新日志来选择版本
- 也支持直接使用分支版本。如:
```yml
- name: Issues Helper
uses: actions-cool/issues-helper@main
```
## Actions 模板
- 可直接使用这个 [GitHub Actions workflow template](https://github.com/actions-cool/.github) 仓库的模板
@@ -924,19 +984,19 @@ x2 + y2
</td>
</tr>
<tr>
<td align="center" wdith="160">
<td align="center" width="160">
<strong>ant-design</strong>
</td>
<td align="center" wdith="160">
<td align="center" width="160">
<strong>ant-design-vue</strong>
</td>
<td align="center" wdith="160">
<td align="center" width="160">
<strong>dumi</strong>
</td>
<td align="center" wdith="160">
<td align="center" width="160">
<strong>umi</strong>
</td>
<td align="center" wdith="160">
<td align="center" width="160">
<strong>vue-request</strong>
</td>
</tr>

View File

@@ -52,6 +52,12 @@ inputs:
description: 'Query use'
inactive-label:
description: 'Issue label set use'
duplicate-command:
description: 'For mark-duplicate'
duplicate-labels:
description: 'For mark-duplicate add labels'
close-issue:
description: 'For mark-duplicate'
outputs:
issue-number:
description: 'Create Issue Number'

114
dist/index.js vendored
View File

@@ -6213,26 +6213,32 @@ async function doQueryIssues (owner, repo, labels, state, creator) {
const res = await octokit.issues.listForRepo(params);
let issues = [];
res.data.forEach(iss => {
const a = bodyIncludes ? iss.body.includes(bodyIncludes) : true;
const b = titleIncludes ? iss.title.includes(titleIncludes) : true;
/**
* Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request.
* For this reason, "Issues" endpoints may return both issues and pull requests in the response.
* You can identify pull requests by the pull_request key.
*/
if (a && b && iss.pull_request === undefined) {
if (inactiveDay && typeof(inactiveDay) === 'number') {
let lastTime = dayjs.utc().subtract(inactiveDay, 'day');
let updateTime = dayjs.utc(iss.updated_at);
if (updateTime.isSameOrBefore(lastTime)) {
let issueNumbers = [];
if (res.data.length) {
res.data.forEach(iss => {
const a = bodyIncludes ? iss.body.includes(bodyIncludes) : true;
const b = titleIncludes ? iss.title.includes(titleIncludes) : true;
/**
* Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request.
* For this reason, "Issues" endpoints may return both issues and pull requests in the response.
* You can identify pull requests by the pull_request key.
*/
if (a && b && iss.pull_request === undefined) {
if (inactiveDay) {
let lastTime = dayjs.utc().subtract(Number(inactiveDay), 'day');
let updateTime = dayjs.utc(iss.updated_at);
if (updateTime.isSameOrBefore(lastTime)) {
issues.push(iss);
issueNumbers.push(iss.number);
}
} else {
issues.push(iss);
issueNumbers.push(iss.number);
}
} else {
issues.push(iss);
}
}
})
})
core.info(`Actions: [query-issues]: [${JSON.stringify(issueNumbers)}]!`);
}
return issues;
};
@@ -6272,7 +6278,7 @@ const ALLREACTIONS = [
"eyes",
];
const { dealInput } = __webpack_require__(6254);
const { dealInput, testDuplicate } = __webpack_require__(6254);
const token = core.getInput('token');
const octokit = new Octokit({ auth: `token ${token}` });
@@ -6280,6 +6286,8 @@ const octokit = new Octokit({ auth: `token ${token}` });
const contents = core.getInput("contents");
const issueContents = core.getInput("issue-contents");
const context = github.context;
async function doAddAssignees (owner, repo, issueNumber, assignees) {
await octokit.issues.addAssignees({
owner,
@@ -6394,6 +6402,47 @@ async function doLockIssue (owner, repo, issueNumber) {
core.info(`Actions: [lock-issue][${issueNumber}] success!`);
};
async function doMarkDuplicate (owner, repo, labels) {
if (context.eventName != 'issue_comment') {
core.info(`This actions only support on 'issue_comment'!`);
return false;
}
if (context.payload.action != 'created') {
core.info(`This actions only support on 'issue_comment' created!`);
return false;
}
const duplicateCommand = core.getInput("duplicate-command");
const duplicateLabels = core.getInput("duplicate-labels");
const closeIssue = core.getInput("close-issue");
const commentId = context.payload.comment.id;
const commentBody = context.payload.comment.body;
const issueNumber = context.payload.issue.number;
const ifCommandInput = !!duplicateCommand;
if ((ifCommandInput && commentBody.startsWith(duplicateCommand) && commentBody.split(' ')[0] == duplicateCommand) || testDuplicate(commentBody)) {
if (ifCommandInput) {
const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of');
await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true);
} else if (contents) {
await doCreateCommentContent(owner, repo, commentId, dealInput(contents));
}
if (duplicateLabels) {
await doAddLabels(owner, repo, issueNumber, duplicateLabels);
}
if (labels) {
await doSetLabels(owner, repo, issueNumber, labels);
}
if (closeIssue == 'true') {
await doCloseIssue(owner, repo, issueNumber);
}
} else {
core.info(`This comment body should start whith 'duplicate-command'`);
}
};
async function doOpenIssue (owner, repo, issueNumber) {
await octokit.issues.update({
owner,
@@ -6460,7 +6509,8 @@ async function doUpdateComment (
repo,
commentId,
body,
updateMode
updateMode,
ifUpdateBody,
) {
const comment = await octokit.issues.getComment({
owner,
@@ -6475,7 +6525,7 @@ async function doUpdateComment (
comment_id: commentId
};
if (core.getInput("body")) {
if (core.getInput("body") || ifUpdateBody) {
if (updateMode === 'append') {
params.body = `${comment_body}\n${body}`;
} else {
@@ -6611,6 +6661,7 @@ module.exports = {
doCreateIssue,
doCreateIssueContent,
doDeleteComment,
doMarkDuplicate,
doLockIssue,
doOpenIssue,
doRemoveAssignees,
@@ -6640,6 +6691,7 @@ const {
doCreateIssue,
doCreateIssueContent,
doDeleteComment,
doMarkDuplicate,
doLockIssue,
doOpenIssue,
doRemoveAssignees,
@@ -6668,6 +6720,7 @@ const ALLACTIONS = [
'create-issue',
'delete-comment',
'lock-issue',
'mark-duplicate',
'open-issue',
'remove-assignees',
'remove-labels',
@@ -6709,7 +6762,9 @@ async function main() {
updateMode = 'replace';
}
// actions
const actions = core.getInput("actions", { required: true });
const actionsArr = actions.split(',');
actionsArr.forEach(item => {
testActions(item.trim());
@@ -6747,6 +6802,9 @@ async function main() {
case 'lock-issue':
await doLockIssue(owner, repo, issueNumber);
break;
case 'mark-duplicate':
await doMarkDuplicate(owner, repo, labels);
break;
case 'open-issue':
await doOpenIssue(owner, repo, issueNumber);
break;
@@ -6862,13 +6920,27 @@ function dealInput (para) {
return arr;
};
function matchKeyword(content, keywords) {
function matchKeyword (content, keywords) {
return keywords.find(item => content.toLowerCase().includes(item));
};
function testDuplicate(body) {
if (!body || !body.startsWith('Duplicate of')) {
return false
}
let arr = body.split(' ');
if (arr[0] == 'Duplicate' && arr[1] == 'of') {
return true;
} else {
return false;
}
};
module.exports = {
dealInput,
matchKeyword,
testDuplicate,
};

View File

@@ -34,6 +34,7 @@ jobs:
| actions | Action type | string | ✔ | v1 |
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ | v1 |
| body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 |
| contents | Add [reaction](/en-US/guide/ref#-reactions-type) for this comment | string | ✖ | v1 |
| labels | Labels filtering | string | ✖ | v1.1 |
| issue-state | State filtering | string | ✖ | v1 |
| issue-assignee | Assignee filtering | string | ✖ | v1 |
@@ -41,7 +42,7 @@ jobs:
| issue-mentioned | Mentioned filtering | string | ✖ | v1 |
| body-includes | Body filtering | string | ✖ | v1 |
| title-includes | Title filtering | string | ✖ | v1 |
| inactive-day | Inactive days filtering | number | ✖ | v1.2 |
| inactive-day | Inactive days filtering | number | ✖ | v1.4 |
| inactive-label | The label name adding | string | ✖ | v1 |
- `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all
@@ -122,13 +123,14 @@ jobs:
| actions | Action type | string | ✔ | v1 |
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ | v1 |
| body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 |
| contents | Add [reaction](/en-US/guide/ref#-reactions-type) for this comment | string | ✖ | v1 |
| labels | Labels filtering | string | ✖ | v1.1 |
| issue-assignee | Assignee filtering | string | ✖ | v1 |
| issue-creator | Creator filtering | string | ✖ | v1 |
| issue-mentioned | Mentioned filtering | string | ✖ | v1 |
| body-includes | Body filtering | string | ✖ | v1 |
| title-includes | Title filtering | string | ✖ | v1 |
| inactive-day | Inactive days filtering | number | ✖ | v1.2 |
| inactive-day | Inactive days filtering | number | ✖ | v1.4 |
- `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all
- `issue-assignee`: Multiplayer is not supported. If you do not enter or enter *, all will be searched. Entering `none` will query issues for which the specified person is not added
@@ -199,6 +201,7 @@ jobs:
| actions | Action type | string | ✔ | v1 |
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ | v1 |
| body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 |
| contents | Add [reaction](/en-US/guide/ref#-reactions-type) for this comment | string | ✖ | v1 |
| labels | Labels filtering | string | ✖ | v1.1 |
| issue-state | State filtering | string | ✖ | v1 |
| issue-assignee | Assignee filtering | string | ✖ | v1 |
@@ -206,7 +209,7 @@ jobs:
| issue-mentioned | Mentioned filtering | string | ✖ | v1 |
| body-includes | Body filtering | string | ✖ | v1 |
| title-includes | Title filtering | string | ✖ | v1 |
| inactive-day | Inactive days filtering | number | ✖ | v1.2 |
| inactive-day | Inactive days filtering | number | ✖ | v1.4 |
- `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all
- `issue-state`: The default is `all`. Optional value `open` `closed`, when these 2 items are not, both are `all`

View File

@@ -34,6 +34,7 @@ jobs:
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 |
| contents | 为该评论增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ | v1 |
| labels | 标签筛选 | string | ✖ | v1.1 |
| issue-state | 状态筛选 | string | ✖ | v1 |
| issue-assignee | 指定人筛选 | string | ✖ | v1 |
@@ -41,7 +42,7 @@ jobs:
| issue-mentioned | 提及人筛选 | string | ✖ | v1 |
| body-includes | 包含内容筛选 | string | ✖ | v1 |
| title-includes | 包含标题筛选 | string | ✖ | v1 |
| inactive-day | 非活跃天数筛选 | number | ✖ | v1.2 |
| inactive-day | 非活跃天数筛选 | number | ✖ | v1.4 |
| inactive-label | 新增标签名称 | string | ✖ | v1 |
- `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有
@@ -118,13 +119,14 @@ jobs:
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 |
| contents | 为该评论增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ | v1 |
| labels | 标签筛选 | string | ✖ | v1.1 |
| issue-assignee | 指定人筛选 | string | ✖ | v1 |
| issue-creator | 创建人筛选 | string | ✖ | v1 |
| issue-mentioned | 提及人筛选 | string | ✖ | v1 |
| body-includes | 包含内容筛选 | string | ✖ | v1 |
| title-includes | 包含标题筛选 | string | ✖ | v1 |
| inactive-day | 非活跃天数筛选 | number | ✖ | v1.2 |
| inactive-day | 非活跃天数筛选 | number | ✖ | v1.4 |
- `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有
- `issue-assignee`:不支持多人。不填或输入 * 时,查询所有。输入 `none` 会查询未添加指定人的 issues
@@ -195,6 +197,7 @@ jobs:
| actions | 操作类型 | string | ✔ | v1 |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ | v1 |
| body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 |
| contents | 为该评论增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ | v1 |
| labels | 标签筛选 | string | ✖ | v1.1 |
| issue-state | 状态筛选 | string | ✖ | v1 |
| issue-assignee | 指定人筛选 | string | ✖ | v1 |
@@ -202,7 +205,7 @@ jobs:
| issue-mentioned | 提及人筛选 | string | ✖ | v1 |
| body-includes | 包含内容筛选 | string | ✖ | v1 |
| title-includes | 包含标题筛选 | string | ✖ | v1 |
| inactive-day | 非活跃天数筛选 | number | ✖ | v1.2 |
| inactive-day | 非活跃天数筛选 | number | ✖ | v1.4 |
- `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有
- `issue-state`:默认为 `all`。可选值 `open` `closed`,非这 2 项时,均为 `all`

View File

@@ -229,6 +229,47 @@ jobs:
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ | v1 |
| issue-number | The number of issue | number | ✔ | v1 |
## `mark-duplicate`
Quickly mark duplicate questions, only for issue new comments.
```yml
name: Issue Mark Duplicate
on:
issue_comment:
types: [created]
jobs:
mark-duplicate:
runs-on: ubuntu-latest
steps:
- name: mark-duplicate
uses: actions-cool/issues-helper@v1.5
with:
actions: 'mark-duplicate'
token: ${{ secrets.GITHUB_TOKEN }}
```
| Param | Desc | Type | Required | Version |
| -- | -- | -- | -- | -- |
| actions | Action type | string | ✔ | v1.5 |
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ | v1.5 |
| duplicate-command | Simple commands can be set, such as: `/d` | string | ✖ | v1.6 |
| duplicate-labels | Add additional labels to this issue | string | ✖ | v1.5 |
| labels | Replace the labels of the issue | string | ✖ | v1.5 |
| contents | Add [reaction](/en-US/guide/ref#-reactions-type) for this comment | string | ✖ | v1.5 |
| close-issue | Whether to close the issue at the same time | string | ✖ | v1.6 |
- `duplicate-command`: When setting concise commands, while still supporting the original `Duplicate of`
- `close-issue`: Both `true` or `'true'` can take effect
<Alert>
Note: Duplicate created with the concise command does not display the content of the red box in the figure below. But in fact this has no effect.
</Alert>
![](../public/duplicate.png)
## `open-issue`
Open the specified issue.

View File

@@ -229,6 +229,47 @@ jobs:
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ | v1 |
| issue-number | 指定的 issue | number | ✔ | v1 |
## `mark-duplicate`
快捷标记重复问题,仅作用于 issue 新增评论。
```yml
name: Issue Mark Duplicate
on:
issue_comment:
types: [created]
jobs:
mark-duplicate:
runs-on: ubuntu-latest
steps:
- name: mark-duplicate
uses: actions-cool/issues-helper@v1.5
with:
actions: 'mark-duplicate'
token: ${{ secrets.GITHUB_TOKEN }}
```
| 参数 | 描述 | 类型 | 必填 | 版本 |
| -- | -- | -- | -- | -- |
| actions | 操作类型 | string | ✔ | v1.5 |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ | v1.5 |
| duplicate-command | 可设置简洁命令,如:`/d` | string | ✖ | v1.6 |
| duplicate-labels | 为该 issue 额外增加 labels | string | ✖ | v1.5 |
| labels | 替换该 issue 的 labels | string | ✖ | v1.5 |
| contents | 为该评论的增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ | v1.5 |
| close-issue | 是否同时关闭该 issue | string | ✖ | v1.6 |
- `duplicate-command`:当设置简洁命令时,同时仍支持原有 `Duplicate of`
- `close-issue``true``'true'` 均可生效
<Alert>
注意:使用简洁命令创建的 Duplicate 不显示下图红框内容。但其实这个没有任何影响的。
</Alert>
![](../public/duplicate.png)
## `open-issue`
打开指定 issue。

View File

@@ -9,7 +9,7 @@ toc: menu
- v1 represents the initial version
- The fixes and additions to the v1 version will be released to the v1.1 version
- When the released v1.x runs stable for a certain period of time, release the advanced v2 version
- It is recommended to use the largest version and above for the parameters in the API
- The parameters in the API must use the largest version and above
- Version selection
- It is recommended to use the latest releases version. It can be seen in [releases](https://github.com/actions-cool/issues-helper/releases)
@@ -21,4 +21,4 @@ toc: menu
uses: actions-cool/issues-helper@main
```
<embed src="./log.md"></embed>
<embed src="../CHANGELOG.md"></embed>

View File

@@ -9,7 +9,7 @@ toc: menu
- v1 表示初始版本
- 对 v1 版本的修复和新增会发布到 v1.1 版本
- 当发布的 v1.x 运行一定时间稳定后,发布进阶 v2 版本
- API 中参数建议使用其中最大及以上版本
- API 中参数使用其中最大及以上版本
- 版本选择
- 建议采用最新 releases 版本。可在 [releases](https://github.com/actions-cool/issues-helper/releases) 看到
@@ -21,4 +21,4 @@ toc: menu
uses: actions-cool/issues-helper@main
```
<embed src="./log.md"></embed>
<embed src="../CHANGELOG.md"></embed>

View File

@@ -1,6 +1,6 @@
{
"name": "issue-helper",
"version": "1.3.0",
"version": "1.6.0",
"private": true,
"description": "Some operations on issue.",
"main": "src/main.js",

BIN
public/duplicate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@@ -186,26 +186,32 @@ async function doQueryIssues (owner, repo, labels, state, creator) {
const res = await octokit.issues.listForRepo(params);
let issues = [];
res.data.forEach(iss => {
const a = bodyIncludes ? iss.body.includes(bodyIncludes) : true;
const b = titleIncludes ? iss.title.includes(titleIncludes) : true;
/**
* Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request.
* For this reason, "Issues" endpoints may return both issues and pull requests in the response.
* You can identify pull requests by the pull_request key.
*/
if (a && b && iss.pull_request === undefined) {
if (inactiveDay && typeof(inactiveDay) === 'number') {
let lastTime = dayjs.utc().subtract(inactiveDay, 'day');
let updateTime = dayjs.utc(iss.updated_at);
if (updateTime.isSameOrBefore(lastTime)) {
let issueNumbers = [];
if (res.data.length) {
res.data.forEach(iss => {
const a = bodyIncludes ? iss.body.includes(bodyIncludes) : true;
const b = titleIncludes ? iss.title.includes(titleIncludes) : true;
/**
* Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request.
* For this reason, "Issues" endpoints may return both issues and pull requests in the response.
* You can identify pull requests by the pull_request key.
*/
if (a && b && iss.pull_request === undefined) {
if (inactiveDay) {
let lastTime = dayjs.utc().subtract(Number(inactiveDay), 'day');
let updateTime = dayjs.utc(iss.updated_at);
if (updateTime.isSameOrBefore(lastTime)) {
issues.push(iss);
issueNumbers.push(iss.number);
}
} else {
issues.push(iss);
issueNumbers.push(iss.number);
}
} else {
issues.push(iss);
}
}
})
})
core.info(`Actions: [query-issues]: [${JSON.stringify(issueNumbers)}]!`);
}
return issues;
};

View File

@@ -16,7 +16,7 @@ const ALLREACTIONS = [
"eyes",
];
const { dealInput } = require('./util.js');
const { dealInput, testDuplicate } = require('./util.js');
const token = core.getInput('token');
const octokit = new Octokit({ auth: `token ${token}` });
@@ -24,6 +24,8 @@ const octokit = new Octokit({ auth: `token ${token}` });
const contents = core.getInput("contents");
const issueContents = core.getInput("issue-contents");
const context = github.context;
async function doAddAssignees (owner, repo, issueNumber, assignees) {
await octokit.issues.addAssignees({
owner,
@@ -138,6 +140,47 @@ async function doLockIssue (owner, repo, issueNumber) {
core.info(`Actions: [lock-issue][${issueNumber}] success!`);
};
async function doMarkDuplicate (owner, repo, labels) {
if (context.eventName != 'issue_comment') {
core.info(`This actions only support on 'issue_comment'!`);
return false;
}
if (context.payload.action != 'created') {
core.info(`This actions only support on 'issue_comment' created!`);
return false;
}
const duplicateCommand = core.getInput("duplicate-command");
const duplicateLabels = core.getInput("duplicate-labels");
const closeIssue = core.getInput("close-issue");
const commentId = context.payload.comment.id;
const commentBody = context.payload.comment.body;
const issueNumber = context.payload.issue.number;
const ifCommandInput = !!duplicateCommand;
if ((ifCommandInput && commentBody.startsWith(duplicateCommand) && commentBody.split(' ')[0] == duplicateCommand) || testDuplicate(commentBody)) {
if (ifCommandInput) {
const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of');
await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true);
} else if (contents) {
await doCreateCommentContent(owner, repo, commentId, dealInput(contents));
}
if (duplicateLabels) {
await doAddLabels(owner, repo, issueNumber, duplicateLabels);
}
if (labels) {
await doSetLabels(owner, repo, issueNumber, labels);
}
if (closeIssue == 'true') {
await doCloseIssue(owner, repo, issueNumber);
}
} else {
core.info(`This comment body should start whith 'duplicate-command'`);
}
};
async function doOpenIssue (owner, repo, issueNumber) {
await octokit.issues.update({
owner,
@@ -204,7 +247,8 @@ async function doUpdateComment (
repo,
commentId,
body,
updateMode
updateMode,
ifUpdateBody,
) {
const comment = await octokit.issues.getComment({
owner,
@@ -219,7 +263,7 @@ async function doUpdateComment (
comment_id: commentId
};
if (core.getInput("body")) {
if (core.getInput("body") || ifUpdateBody) {
if (updateMode === 'append') {
params.body = `${comment_body}\n${body}`;
} else {
@@ -355,6 +399,7 @@ module.exports = {
doCreateIssue,
doCreateIssueContent,
doDeleteComment,
doMarkDuplicate,
doLockIssue,
doOpenIssue,
doRemoveAssignees,

View File

@@ -10,6 +10,7 @@ const {
doCreateIssue,
doCreateIssueContent,
doDeleteComment,
doMarkDuplicate,
doLockIssue,
doOpenIssue,
doRemoveAssignees,
@@ -38,6 +39,7 @@ const ALLACTIONS = [
'create-issue',
'delete-comment',
'lock-issue',
'mark-duplicate',
'open-issue',
'remove-assignees',
'remove-labels',
@@ -79,7 +81,9 @@ async function main() {
updateMode = 'replace';
}
// actions
const actions = core.getInput("actions", { required: true });
const actionsArr = actions.split(',');
actionsArr.forEach(item => {
testActions(item.trim());
@@ -117,6 +121,9 @@ async function main() {
case 'lock-issue':
await doLockIssue(owner, repo, issueNumber);
break;
case 'mark-duplicate':
await doMarkDuplicate(owner, repo, labels);
break;
case 'open-issue':
await doOpenIssue(owner, repo, issueNumber);
break;

View File

@@ -11,11 +11,25 @@ function dealInput (para) {
return arr;
};
function matchKeyword(content, keywords) {
function matchKeyword (content, keywords) {
return keywords.find(item => content.toLowerCase().includes(item));
};
function testDuplicate(body) {
if (!body || !body.startsWith('Duplicate of')) {
return false
}
let arr = body.split(' ');
if (arr[0] == 'Duplicate' && arr[1] == 'of') {
return true;
} else {
return false;
}
};
module.exports = {
dealInput,
matchKeyword,
testDuplicate,
};