diff --git a/README.en-US.md b/README.en-US.md index 760dc786..922f8622 100644 --- a/README.en-US.md +++ b/README.en-US.md @@ -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) @@ -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` diff --git a/README.md b/README.md index fa85de0d..f7613b4e 100644 --- a/README.md +++ b/README.md @@ -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` ⏫ [返回列表](#列-表) @@ -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` diff --git a/action.yml b/action.yml index b12e9e06..36df7dd7 100644 --- a/action.yml +++ b/action.yml @@ -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: diff --git a/dist/index.js b/dist/index.js index b85b3edf..8e90dd08 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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!`); } diff --git a/docs/advanced.en-US.md b/docs/advanced.en-US.md index 556090ba..bd3bb1db 100644 --- a/docs/advanced.en-US.md +++ b/docs/advanced.en-US.md @@ -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` diff --git a/docs/advanced.md b/docs/advanced.md index c4ecf1ec..4a74e3c9 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -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` diff --git a/docs/base.en-US.md b/docs/base.en-US.md index 8ade6aba..1a89757d 100644 --- a/docs/base.en-US.md +++ b/docs/base.en-US.md @@ -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` diff --git a/docs/base.md b/docs/base.md index 13baa450..142d3558 100644 --- a/docs/base.md +++ b/docs/base.md @@ -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` diff --git a/src/base.js b/src/base.js index 903f231c..0e5d4a60 100644 --- a/src/base.js +++ b/src/base.js @@ -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!`); }