From 616c112b129b7034e2b070a3a575f46ddf0c465d Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Tue, 26 Jan 2021 22:17:55 +0800 Subject: [PATCH] feat: add lock-reason (#49) * feat: add lock-reason * add dist --- README.en-US.md | 4 ++++ README.md | 4 ++++ action.yml | 2 ++ dist/index.js | 10 ++++++++-- docs/advanced.en-US.md | 1 + docs/advanced.md | 1 + docs/base.en-US.md | 3 +++ docs/base.md | 3 +++ src/base.js | 10 ++++++++-- 9 files changed, 34 insertions(+), 4 deletions(-) diff --git a/README.en-US.md b/README.en-US.md index 760dc78..922f862 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 fa85de0..f7613b4 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 b12e9e0..36df7dd 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 b85b3ed..8e90dd0 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 556090b..bd3bb1d 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 c4ecf1e..4a74e3c 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 8ade6ab..1a89757 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 13baa45..142d355 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 903f231..0e5d4a6 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!`); }