From 6ef8e78ed12643911b43900021c6236cd2fd792f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=83=E5=87=9B?= Date: Mon, 1 Aug 2022 10:33:44 +0800 Subject: [PATCH] refactor: add default `body-include` --- CHANGELOG.md | 6 ++++++ README.md | 3 +-- dist/index.js | 15 +++++++++------ src/main.js | 15 +++++++++------ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 117dfde..fdd62cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ # Changelog +## v3.0.0 + +`2022.08.01` + +- refactor: add default `body-include`. + ## v2.0.2 `2021.10.19` diff --git a/README.md b/README.md index b37a266..1912660 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,11 @@ jobs: runs-on: ubuntu-latest steps: - name: maintain-comment - uses: actions-cool/maintain-one-comment@v2 + uses: actions-cool/maintain-one-comment@v3 with: token: ${{ secrets.GITHUB_TOKEN }} body: | Hi 😀 - emojis: '+1, laugh' body-include: '' ``` diff --git a/dist/index.js b/dist/index.js index 363a926..e2204fc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9631,6 +9631,7 @@ const { Octokit } = __nccwpck_require__(5375); const token = core.getInput('token'); const octokit = new Octokit({ auth: `token ${token}` }); const context = github.context; +const defaultBody = ''; const { dealStringToArr, THANKS } = __nccwpck_require__(55); @@ -9650,7 +9651,7 @@ async function run() { // 筛选评论 const commentAuth = core.getInput('comment-auth'); - const bodyInclude = core.getInput('body-include'); + const bodyInclude = core.getInput('body-include') || defaultBody; // 手动 number const inputNumber = core.getInput('number'); @@ -9700,13 +9701,14 @@ async function run() { core.info(`filter-comments: ${JSON.stringify(comments)}`); core.info(`filter-comments-length: ${comments.length}`); if (comments.length === 0) { + const commentBody = `${body}\n${bodyInclude}`; const { data } = await octokit.issues.createComment({ owner, repo, issue_number: number, - body, + body: commentBody, }); - core.info(`Actions: [create-comment][${body}] success!`); + core.info(`Actions: [create-comment][${commentBody}] success!`); core.setOutput('comment-id', data.id); if (emojis) { @@ -9746,12 +9748,13 @@ async function run() { comment_id: commentId, }; + let commentBody; if (updateMode === 'append') { - params.body = `${comment_body}\n${body}`; + commentBody = `${comment_body}\n${body}`; } else { - params.body = body; + commentBody = body; } - + params.body = `${commentBody}\n${bodyInclude}`; await octokit.issues.updateComment(params); core.setOutput('comment-id', commentId); core.info(`Actions: [update-comment][${params.body}] success!`); diff --git a/src/main.js b/src/main.js index d785acc..2ef48ec 100644 --- a/src/main.js +++ b/src/main.js @@ -6,6 +6,7 @@ const { Octokit } = require('@octokit/rest'); const token = core.getInput('token'); const octokit = new Octokit({ auth: `token ${token}` }); const context = github.context; +const defaultBody = ''; const { dealStringToArr, THANKS } = require('actions-util'); @@ -25,7 +26,7 @@ async function run() { // 筛选评论 const commentAuth = core.getInput('comment-auth'); - const bodyInclude = core.getInput('body-include'); + const bodyInclude = core.getInput('body-include') || defaultBody; // 手动 number const inputNumber = core.getInput('number'); @@ -75,13 +76,14 @@ async function run() { core.info(`filter-comments: ${JSON.stringify(comments)}`); core.info(`filter-comments-length: ${comments.length}`); if (comments.length === 0) { + const commentBody = `${body}\n${bodyInclude}`; const { data } = await octokit.issues.createComment({ owner, repo, issue_number: number, - body, + body: commentBody, }); - core.info(`Actions: [create-comment][${body}] success!`); + core.info(`Actions: [create-comment][${commentBody}] success!`); core.setOutput('comment-id', data.id); if (emojis) { @@ -121,12 +123,13 @@ async function run() { comment_id: commentId, }; + let commentBody; if (updateMode === 'append') { - params.body = `${comment_body}\n${body}`; + commentBody = `${comment_body}\n${body}`; } else { - params.body = body; + commentBody = body; } - + params.body = `${commentBody}\n${bodyInclude}`; await octokit.issues.updateComment(params); core.setOutput('comment-id', commentId); core.info(`Actions: [update-comment][${params.body}] success!`);