Skip to content

Commit

Permalink
feat: add lock-reason (#49)
Browse files Browse the repository at this point in the history
* feat: add lock-reason

* add dist
  • Loading branch information
xrkffgg authored Jan 26, 2021
1 parent 1425c33 commit 616c112
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ jobs:
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| issue-number | The number of issue | number | ✔ |
| lock-reason | Reason for locking issue | string | ✖ |

- `lock-reason`: Optional values are `off-topic` `too heated` `resolved` `spam`

⏫ [Back to list](#List)

Expand Down Expand Up @@ -861,6 +864,7 @@ jobs:
| body-includes | Body filtering | string | ✖ |
| title-includes | Title filtering | string | ✖ |
| inactive-day | Inactive days filtering | number | ✖ |
| lock-reason | Reason for locking issue | string | ✖ |

- `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`
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ jobs:
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| issue-number | 指定的 issue | number | ✔ |
| lock-reason | 锁定 issue 的原因 | string | ✖ |

- `lock-reason`:可选值有 `off-topic` `too heated` `resolved` `spam`

⏫ [返回列表](#列-表)

Expand Down Expand Up @@ -855,6 +858,7 @@ jobs:
| body-includes | 包含内容筛选 | string | ✖ |
| title-includes | 包含标题筛选 | string | ✖ |
| inactive-day | 非活跃天数筛选 | number | ✖ |
| lock-reason | 锁定 issue 的原因 | string | ✖ |

- `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有
- `issue-state`:默认为 `open`。可选值 `all` `closed`,非这 2 项时,均为 `open`
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ inputs:
description: 'Query use'
inactive-day:
description: 'Query use'
lock-reason:
description: 'The reason lock issue'
inactive-label:
description: 'Issue label set use'
duplicate-command:
Expand Down
10 changes: 8 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7995,11 +7995,17 @@ async function doDeleteComment(owner, repo, commentId) {
}

async function doLockIssue(owner, repo, issueNumber) {
await octokit.issues.lock({
const lockReason = core.getInput('lock-reason');
let params = {
owner,
repo,
issue_number: issueNumber,
});
};
const reasons = ['off-topic', 'too heated', 'resolved', 'spam'];
if (lockReason && reasons.includes(lockReason)) {
params.lock_reason = lockReason;
}
await octokit.issues.lock(params);
core.info(`Actions: [lock-issue][${issueNumber}] success!`);
}

Expand Down
1 change: 1 addition & 0 deletions docs/advanced.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ jobs:
| body-includes | Body filtering | string | ✖ |
| title-includes | Title filtering | string | ✖ |
| inactive-day | Inactive days filtering | number | ✖ |
| lock-reason | Reason for locking issue | string | ✖ |

- `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`
Expand Down
1 change: 1 addition & 0 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ jobs:
| body-includes | 包含内容筛选 | string | ✖ |
| title-includes | 包含标题筛选 | string | ✖ |
| inactive-day | 非活跃天数筛选 | number | ✖ |
| lock-reason | 锁定 issue 的原因 | string | ✖ |

- `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有
- `issue-state`:默认为 `all`。可选值 `open` `closed`,非这 2 项时,均为 `all`
Expand Down
3 changes: 3 additions & 0 deletions docs/base.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ jobs:
| actions | Action type | string | ✔ |
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ |
| issue-number | The number of issue | number | ✔ |
| lock-reason | Reason for locking issue | string | ✖ |

- `lock-reason`: Optional values are `off-topic` `too heated` `resolved` `spam`

## `mark-duplicate`

Expand Down
3 changes: 3 additions & 0 deletions docs/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ jobs:
| actions | 操作类型 | string | ✔ |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ |
| issue-number | 指定的 issue | number | ✔ |
| lock-reason | 锁定 issue 的原因 | string | ✖ |

- `lock-reason`:可选值有 `off-topic` `too heated` `resolved` `spam`

## `mark-duplicate`

Expand Down
10 changes: 8 additions & 2 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,17 @@ async function doDeleteComment(owner, repo, commentId) {
}

async function doLockIssue(owner, repo, issueNumber) {
await octokit.issues.lock({
const lockReason = core.getInput('lock-reason');
let params = {
owner,
repo,
issue_number: issueNumber,
});
};
const reasons = ['off-topic', 'too heated', 'resolved', 'spam'];
if (lockReason && reasons.includes(lockReason)) {
params.lock_reason = lockReason;
}
await octokit.issues.lock(params);
core.info(`Actions: [lock-issue][${issueNumber}] success!`);
}

Expand Down

0 comments on commit 616c112

Please sign in to comment.