diff --git a/README.en-US.md b/README.en-US.md
index cd00a17..2e52e0b 100644
--- a/README.en-US.md
+++ b/README.en-US.md
@@ -379,6 +379,9 @@ According to [`comment-id`](#comment-id) delete the specified comment.
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| comment-id | The comment ID | number | ✔ |
+| out-comments | The output of `find-comments`, if you find multiple, operate multiple | string | ✖ |
+
+- When `out-comments` is entered, `comment-id` does not work
⏫ [Back to list](#List)
@@ -606,12 +609,14 @@ jobs:
| actions | Action type | string | ✔ |
| token | [Token explain](#token) | string | ✔ |
| comment-id | The comment ID | number | ✔ |
+| out-comments | The output of `find-comments`, if you find multiple, operate multiple | string | ✖ |
| body | Update the content of comment | string | ✖ |
| update-mode | Update mode. Default `replace`, another `append` | string | ✖ |
| contents | Add [reaction](#reactions-types) | string | ✖ |
- When `body` is not entered, it will remain as it is
- When `update-mode` is `append`, additional operations will be performed. Anything other than `append` will be replaced. Only effective for `body`
+- When `out-comments` is entered, `comment-id` does not work
⏫ [Back to list](#List)
@@ -963,13 +968,15 @@ Flexible reference.
### `find-comments + create-comment + update-comment`
-Hypothetical scenario: When the issue modification of the `watch` label is added, find out whether there is a comment containing `error` created by k, if there is only one, update the comment, if not, add a new comment.
+Hypothetical scenario: When the issue modification of the `watch` label is added, find out whether there is a comment created by k that contains ``, if so, update the comment, If not, add a comment.
+
+Of course, if you need such a scene, you can directly use [**Maintain One Comment**](https://github.com/actions-cool/maintain-one-comment).
```yml
name: Test
on:
- isssue:
+ issues:
types: [edited]
jobs:
@@ -985,25 +992,33 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
comment-auth: k
- body-includes: 'error'
+ body-includes: ''
+
+ # Output view found content. GitHub default outputs are strings
+ - run: echo find-comments ${{ steps.fcid.outputs.comments }}
+ shell: bash
- name: create comment
- if: ${{ steps.fcid.outputs.comments.length == 0 }}
+ if: contains(steps.fcid.outputs.comments, '') == false
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
- body: 'Some error!'
+ body: |
+ Error
+
- name: update comment
- if: ${{ steps.fcid.outputs.comments.length == 1 }}
+ if: contains(steps.fcid.outputs.comments, '') == true
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
- comment-id: ${{ steps.fcid.outputs.comments[0].id }}
- body: 'Some error again!'
+ out-comments: ${{ steps.fcid.outputs.comments }}
+ body: |
+ Error Again
+
update-mode: 'append'
```
@@ -1022,7 +1037,14 @@ Need to have the person token with push permission.
- `Name` is the same as in actions
- `Value` fill in the token just applied by the individual
-When the token is not filled in actions or the corresponding secrets are not added to the project, it will default to github-actions bot. [More](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow).
+When the token is not filled in actions or input `${{ secrets.GITHUB_TOKEN }}`, it will default to `github-actions-bot`. [More](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow).
+
+⏫ [Back to list](#List)
+
+### GitHub Docs
+
+- [Workflow syntax for GitHub Actions](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
+- [Events that trigger workflows](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
⏫ [Back to list](#List)
@@ -1039,12 +1061,10 @@ When the token is not filled in actions or the corresponding secrets are not add
run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}"
```
-[More](https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs).
+More:
-### GitHub Docs
-
-- [Workflow syntax for GitHub Actions](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
-- [Events that trigger workflows](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
+1. https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs
+2. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs
⏫ [Back to list](#List)
@@ -1123,6 +1143,8 @@ Click the `···` icon in the upper right corner of a comment, select `Copy lin
uses: actions-cool/issues-helper@1.x
```
+- v2 [upgrade reference](https://github.com/actions-cool/issues-helper/blob/fix/docs/guide/faq.en-US.md#what-should-i-pay-attention-to-when-upgrading-from-v1x-to-v2)
+
## Actions Template
- You can directly use this [GitHub Actions workflow template](https://github.com/actions-cool/.github) repositorie template
diff --git a/README.md b/README.md
index b2bafb7..feeb81d 100644
--- a/README.md
+++ b/README.md
@@ -379,6 +379,9 @@ jobs:
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| comment-id | 指定的 comment | number | ✔ |
+| out-comments | `find-comments` 的输出,若查找多个,则操作多个 | string | ✖ |
+
+- 当 `out-comments` 输入时,`comment-id` 不起作用
⏫ [返回列表](#列-表)
@@ -606,12 +609,14 @@ jobs:
| actions | 操作类型 | string | ✔ |
| token | [token 说明](#token) | string | ✔ |
| comment-id | 指定的 comment | number | ✔ |
+| out-comments | `find-comments` 的输出,若查找多个,则操作多个 | string | ✖ |
| body | 更新 comment 的内容 | string | ✖ |
| update-mode | 更新模式。默认 `replace` 替换,`append` 附加 | string | ✖ |
| contents | 增加 [reaction](#reactions-types) | string | ✖ |
- `body` 不填时,会保持原有
- `update-mode` 为 `append` 时,会进行附加操作。非 `append` 都会进行替换。仅对 `body` 生效
+- 当 `out-comments` 输入时,`comment-id` 不起作用
⏫ [返回列表](#列-表)
@@ -957,13 +962,15 @@ jobs:
### `find-comments + create-comment + update-comment`
-假设场景:当添加了 `watch` label 的 issue 修改时,查找是否有 k 创建的包含 `error` 的评论,如果只有一个,则更新该 comment,如果没有,则新增一个 comment。
+假设场景:当添加了 `watch` label 的 issue 修改时,查找是否有 k 创建的包含 `` 的评论,如果有,则更新 comment,如果没有,则新增一个 comment。
+
+当然,如果你需要这样的场景,可以直接使用 [**Maintain One Comment**](https://github.com/actions-cool/maintain-one-comment)。
```yml
name: Test
on:
- isssue:
+ issues:
types: [edited]
jobs:
@@ -979,25 +986,33 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
comment-auth: k
- body-includes: 'error'
+ body-includes: ''
+
+ # 输出查看找到的内容。GitHub 默认 outputs 为字符串
+ - run: echo find-comments ${{ steps.fcid.outputs.comments }}
+ shell: bash
- name: create comment
- if: ${{ steps.fcid.outputs.comments.length == 0 }}
+ if: contains(steps.fcid.outputs.comments, '') == false
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
- body: 'Some error!'
+ body: |
+ Error
+
- name: update comment
- if: ${{ steps.fcid.outputs.comments.length == 1 }}
+ if: contains(steps.fcid.outputs.comments, '') == true
uses: actions-cool/issues-helper@v2.1.1
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
- comment-id: ${{ steps.fcid.outputs.comments[0].id }}
- body: 'Some error again!'
+ out-comments: ${{ steps.fcid.outputs.comments }}
+ body: |
+ Error Again
+
update-mode: 'append'
```
@@ -1016,7 +1031,14 @@ jobs:
- `Name` 与 actions 中保持一致
- `Value` 填写刚才个人申请的 token
-当 actions 不填写 token 时,或项目未添加对应 secrets 时,会默认为 github-actions bot。[更多查看](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow)。
+当 actions 不填写 token 时,或填写 `${{ secrets.GITHUB_TOKEN }}`,会默认为 `github-actions-bot`。[更多查看](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow)。
+
+⏫ [返回列表](#列-表)
+
+### GitHub Docs
+
+- [GitHub Actions 语法](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
+- [工作流触发机制](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
⏫ [返回列表](#列-表)
@@ -1033,12 +1055,10 @@ jobs:
run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}"
```
-[更多查看](https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs)。
+更多查看:
-### GitHub Docs
-
-- [GitHub Actions 语法](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#on)
-- [工作流触发机制](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows)
+1. https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs
+2. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs
⏫ [返回列表](#列-表)
@@ -1118,6 +1138,8 @@ x2 + y2
uses: actions-cool/issues-helper@1.x
```
+- v2 [升级参考](https://github.com/actions-cool/issues-helper/blob/fix/docs/guide/faq.md#%E4%BB%8E-v1x-%E5%8D%87%E7%BA%A7%E5%88%B0-v2%E6%9C%89%E4%BB%80%E4%B9%88%E6%B3%A8%E6%84%8F%E7%9A%84%E5%9C%B0%E6%96%B9%E5%90%97)
+
## Actions 模板
- 可直接使用这个 [GitHub Actions workflow template](https://github.com/actions-cool/.github) 仓库的模板
diff --git a/action.yml b/action.yml
index db4c1d2..b32e747 100644
--- a/action.yml
+++ b/action.yml
@@ -40,8 +40,12 @@ inputs:
description: 'Issue reactions emoji'
direction:
description: 'Find comments direction'
+
+ # comments
comment-auth:
description: 'Find comments query auth'
+ out-comments:
+ description: 'Find comments out comments'
assignee-includes:
description: 'Check use'
body-includes:
diff --git a/dist/index.js b/dist/index.js
index 9a49cb3..d2ee54b 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -7705,6 +7705,7 @@ async function doFindComments(owner, repo, issueNumber) {
}
});
core.setOutput('comments', comments);
+ core.info(`out-comments: ${JSON.stringify(comments)}`);
}
async function doLockIssues(owner, repo, labels) {
@@ -8010,12 +8011,27 @@ async function doCreateLabel(owner, repo) {
}
async function doDeleteComment(owner, repo, commentId) {
- await octokit.issues.deleteComment({
- owner,
- repo,
- comment_id: commentId,
- });
- core.info(`Actions: [delete-comment][${commentId}] success!`);
+ let id = commentId;
+
+ const outComments = core.getInput('out-comments');
+ if (outComments) {
+ const outCommentsArr = JSON.parse(outComments);
+ core.info(`Actions: [out-comments-length][${outCommentsArr.length}] success!`);
+ outCommentsArr.forEach(async item => {
+ await doDelet(item.id);
+ });
+ } else {
+ await doDelet(id);
+ }
+
+ async function doDelet(id) {
+ await octokit.issues.deleteComment({
+ owner,
+ repo,
+ comment_id: id,
+ });
+ core.info(`Actions: [delete-comment][${id}] success!`);
+ }
}
async function doLockIssue(owner, repo, issueNumber) {
@@ -8193,32 +8209,47 @@ async function doUnlockIssue(owner, repo, issueNumber) {
}
async function doUpdateComment(owner, repo, commentId, body, updateMode, ifUpdateBody) {
- const comment = await octokit.issues.getComment({
- owner,
- repo,
- comment_id: commentId,
- });
- const comment_body = comment.data.body;
+ let id = commentId;
- let params = {
- owner,
- repo,
- comment_id: commentId,
- };
-
- if (core.getInput('body') || ifUpdateBody) {
- if (updateMode === 'append') {
- params.body = `${comment_body}\n${body}`;
- } else {
- params.body = body;
- }
-
- await octokit.issues.updateComment(params);
- core.info(`Actions: [update-comment][${commentId}] success!`);
+ const outComments = core.getInput('out-comments');
+ if (outComments) {
+ const outCommentsArr = JSON.parse(outComments);
+ core.info(`Actions: [out-comments-length][${outCommentsArr.length}] success!`);
+ outCommentsArr.forEach(async item => {
+ await doComment(item.id);
+ });
+ } else {
+ await doComment(id);
}
- if (contents) {
- await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents));
+ async function doComment(id) {
+ const comment = await octokit.issues.getComment({
+ owner,
+ repo,
+ comment_id: id,
+ });
+ const comment_body = comment.data.body;
+
+ let params = {
+ owner,
+ repo,
+ comment_id: id,
+ };
+
+ if (core.getInput('body') || ifUpdateBody) {
+ if (updateMode === 'append') {
+ params.body = `${comment_body}\n${body}`;
+ } else {
+ params.body = body;
+ }
+
+ await octokit.issues.updateComment(params);
+ core.info(`Actions: [update-comment][${id}] success!`);
+ }
+
+ if (contents) {
+ await doCreateCommentContent(owner, repo, id, dealStringToArr(contents));
+ }
}
}
diff --git a/docs/base.en-US.md b/docs/base.en-US.md
index 9bac4e6..bce7b0c 100644
--- a/docs/base.en-US.md
+++ b/docs/base.en-US.md
@@ -227,6 +227,9 @@ According to [`comment-id`](/en-US/guide/ref#-comment-id) delete the specified c
| actions | Action type | string | ✔ |
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ |
| comment-id | The comment ID | number | ✔ |
+| out-comments | The output of `find-comments`, if you find multiple, operate multiple | string | ✖ |
+
+- When `out-comments` is entered, `comment-id` does not work
## `lock-issue`
@@ -444,12 +447,14 @@ jobs:
| actions | Action type | string | ✔ |
| token | [Token explain](/en-US/guide/ref#-token) | string | ✔ |
| comment-id | The comment ID | number | ✔ |
+| out-comments | The output of `find-comments`, if you find multiple, operate multiple | string | ✖ |
| body | Update the content of comment | string | ✖ |
| update-mode | Update mode. Default `replace`, another `append` | string | ✖ |
| contents | Add [reaction](/en-US/guide/ref#-reactions-type) | string | ✖ |
- When `body` is not entered, it will remain as it is
- When `update-mode` is `append`, additional operations will be performed. Anything other than `append` will be replaced. Only effective for `body`
+- When `out-comments` is entered, `comment-id` does not work
## `update-issue`
diff --git a/docs/base.md b/docs/base.md
index 3c31378..0baf73b 100644
--- a/docs/base.md
+++ b/docs/base.md
@@ -227,6 +227,9 @@ jobs:
| actions | 操作类型 | string | ✔ |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ |
| comment-id | 指定的 comment | number | ✔ |
+| out-comments | `find-comments` 的输出,若查找多个,则操作多个 | string | ✖ |
+
+- 当 `out-comments` 输入时,`comment-id` 不起作用
## `lock-issue`
@@ -444,12 +447,14 @@ jobs:
| actions | 操作类型 | string | ✔ |
| token | [token 说明](/guide/ref#-token-说明) | string | ✔ |
| comment-id | 指定的 comment | number | ✔ |
+| out-comments | `find-comments` 的输出,若查找多个,则操作多个 | string | ✖ |
| body | 更新 comment 的内容 | string | ✖ |
| update-mode | 更新模式。默认 `replace` 替换,`append` 附加 | string | ✖ |
| contents | 增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ |
- `body` 不填时,会保持原有
- `update-mode` 为 `append` 时,会进行附加操作。非 `append` 都会进行替换。仅对 `body` 生效
+- 当 `out-comments` 输入时,`comment-id` 不起作用
## `update-issue`
diff --git a/docs/changelog.en-US.md b/docs/changelog.en-US.md
index c56e7bc..e31b010 100644
--- a/docs/changelog.en-US.md
+++ b/docs/changelog.en-US.md
@@ -27,4 +27,6 @@ toc: menu
uses: actions-cool/issues-helper@1.x
```
+- v2 [upgrade reference](/en-US/guide/faq)
+
diff --git a/docs/changelog.md b/docs/changelog.md
index d3bf4ac..c0b5fc7 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -27,4 +27,6 @@ toc: menu
uses: actions-cool/issues-helper@1.x
```
+- v2 [升级参考](/guide/faq)
+
diff --git a/docs/guide/note.en-US.md b/docs/guide/note.en-US.md
index e6d6251..cbf098e 100644
--- a/docs/guide/note.en-US.md
+++ b/docs/guide/note.en-US.md
@@ -28,7 +28,7 @@ with:
- `count-lables`: Regardless of setting `true` or `'ture'`, all received in the program is in string format
-At the same time, the output is also in string format
+At the same time, the output is also in string format. [See](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs).
- `check-result`: The judgment condition is `if: steps.xxid.outputs.check-result =='true'`
diff --git a/docs/guide/note.md b/docs/guide/note.md
index 54d127c..34b0cc5 100644
--- a/docs/guide/note.md
+++ b/docs/guide/note.md
@@ -29,7 +29,7 @@ with:
- `count-lables`:不管设置 `true` 还是 `'ture'`,在程序里接收到的都是字符串格式
-同时输出的也是字符串格式
+同时输出的也是字符串格式。[参看](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs)。
- `check-result`:判断条件为 `if: steps.xxid.outputs.check-result == 'true'`
diff --git a/docs/guide/ref.en-US.md b/docs/guide/ref.en-US.md
index 5fc749e..49e5bac 100644
--- a/docs/guide/ref.en-US.md
+++ b/docs/guide/ref.en-US.md
@@ -13,7 +13,7 @@ Need to have the person token with push permission.
- `Name` is the same as in actions
- `Value` fill in the token just applied by the individual
-When the token is not filled in actions or the corresponding secrets are not added to the project, it will default to `github-actions-bot`. [More](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow).
+When the token is not filled in actions or input `${{ secrets.GITHUB_TOKEN }}`, it will default to `github-actions-bot`. [More](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow).
## 📍 GitHub Docs
@@ -33,7 +33,10 @@ When the token is not filled in actions or the corresponding secrets are not add
run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}"
```
-[More](https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs).
+More:
+
+1. https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs
+2. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs
## 📍 `includes` check rules
diff --git a/docs/guide/ref.md b/docs/guide/ref.md
index f714544..085248e 100644
--- a/docs/guide/ref.md
+++ b/docs/guide/ref.md
@@ -13,7 +13,7 @@ toc: menu
- `Name` 与 actions 中保持一致
- `Value` 填写刚才个人申请的 token
-当 actions 不填写 token 时,或项目未添加对应 secrets 时,会默认为 `github-actions-bot`。[更多查看](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow)。
+当 actions 不填写 token 时,或输入 `${{ secrets.GITHUB_TOKEN }}`,会默认为 `github-actions-bot`。[更多查看](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow)。
## 📍 GitHub 相关文档
@@ -33,7 +33,10 @@ toc: menu
run: echo "Outputs issue_number is ${{ steps.createissue.outputs.issue-number }}"
```
-[更多查看](https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs)。
+更多查看:
+
+1. https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/metadata-syntax-for-github-actions#outputs
+2. https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs
## 📍 `includes` 校验规则
diff --git a/src/advanced.js b/src/advanced.js
index e8d64c1..8fb8c11 100644
--- a/src/advanced.js
+++ b/src/advanced.js
@@ -147,6 +147,7 @@ async function doFindComments(owner, repo, issueNumber) {
}
});
core.setOutput('comments', comments);
+ core.info(`out-comments: ${JSON.stringify(comments)}`);
}
async function doLockIssues(owner, repo, labels) {
diff --git a/src/base.js b/src/base.js
index d07ca59..70750a2 100644
--- a/src/base.js
+++ b/src/base.js
@@ -147,12 +147,27 @@ async function doCreateLabel(owner, repo) {
}
async function doDeleteComment(owner, repo, commentId) {
- await octokit.issues.deleteComment({
- owner,
- repo,
- comment_id: commentId,
- });
- core.info(`Actions: [delete-comment][${commentId}] success!`);
+ let id = commentId;
+
+ const outComments = core.getInput('out-comments');
+ if (outComments) {
+ const outCommentsArr = JSON.parse(outComments);
+ core.info(`Actions: [out-comments-length][${outCommentsArr.length}] success!`);
+ outCommentsArr.forEach(async item => {
+ await doDelet(item.id);
+ });
+ } else {
+ await doDelet(id);
+ }
+
+ async function doDelet(id) {
+ await octokit.issues.deleteComment({
+ owner,
+ repo,
+ comment_id: id,
+ });
+ core.info(`Actions: [delete-comment][${id}] success!`);
+ }
}
async function doLockIssue(owner, repo, issueNumber) {
@@ -330,32 +345,47 @@ async function doUnlockIssue(owner, repo, issueNumber) {
}
async function doUpdateComment(owner, repo, commentId, body, updateMode, ifUpdateBody) {
- const comment = await octokit.issues.getComment({
- owner,
- repo,
- comment_id: commentId,
- });
- const comment_body = comment.data.body;
+ let id = commentId;
- let params = {
- owner,
- repo,
- comment_id: commentId,
- };
-
- if (core.getInput('body') || ifUpdateBody) {
- if (updateMode === 'append') {
- params.body = `${comment_body}\n${body}`;
- } else {
- params.body = body;
- }
-
- await octokit.issues.updateComment(params);
- core.info(`Actions: [update-comment][${commentId}] success!`);
+ const outComments = core.getInput('out-comments');
+ if (outComments) {
+ const outCommentsArr = JSON.parse(outComments);
+ core.info(`Actions: [out-comments-length][${outCommentsArr.length}] success!`);
+ outCommentsArr.forEach(async item => {
+ await doComment(item.id);
+ });
+ } else {
+ await doComment(id);
}
- if (contents) {
- await doCreateCommentContent(owner, repo, commentId, dealStringToArr(contents));
+ async function doComment(id) {
+ const comment = await octokit.issues.getComment({
+ owner,
+ repo,
+ comment_id: id,
+ });
+ const comment_body = comment.data.body;
+
+ let params = {
+ owner,
+ repo,
+ comment_id: id,
+ };
+
+ if (core.getInput('body') || ifUpdateBody) {
+ if (updateMode === 'append') {
+ params.body = `${comment_body}\n${body}`;
+ } else {
+ params.body = body;
+ }
+
+ await octokit.issues.updateComment(params);
+ core.info(`Actions: [update-comment][${id}] success!`);
+ }
+
+ if (contents) {
+ await doCreateCommentContent(owner, repo, id, dealStringToArr(contents));
+ }
}
}