提交 b0527a12 编写于 作者: sinat_25235033's avatar sinat_25235033

support bot custom note message

上级 f3478beb
......@@ -14,5 +14,6 @@ jobs:
# with:
# BOT_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
with:
IS_MODIFY_TITLE: true
IS_MODIFY_TITLE: true
CUSTOM_BOT_NOTE: custom message - Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿
......@@ -11,6 +11,8 @@ inputs:
description: 'The issue comment bot github login name.'
IS_MODIFY_TITLE:
description: 'Is need modify issue title, true or false, default false.'
CUSTOM_BOT_NOTE:
description: 'Custom bot note message.'
runs:
using: 'node12'
main: 'dist/index.js'
此差异由.gitattributes 抑制。
此差异由.gitattributes 抑制。
......@@ -22,22 +22,23 @@ async function run(): Promise<void> {
let issueUser = null
let botNote = "Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿"
let isModifyTitle = core.getInput('IS_MODIFY_TITLE')
let translateOrigin = null
if (github.context.eventName === 'issue_comment') {
const issueCommentPayload = github.context
.payload as webhook.EventPayloads.WebhookPayloadIssueComment
issueNumber = issueCommentPayload.issue.number
issueUser = issueCommentPayload.comment.user.login
originComment = issueCommentPayload.comment.body
translateOrigin = originComment
} else {
const issuePayload = github.context.payload as webhook.EventPayloads.WebhookPayloadIssues
issueNumber = issuePayload.issue.number
issueUser = issuePayload.issue.user.login
originComment = issuePayload.issue.body
originTitle = issuePayload.issue.title
translateOrigin = originComment + '@====@' + originTitle
}
let translateOrigin = originComment + '@====@' + originTitle
// detect issue title comment body is english
if (detectIsEnglish(translateOrigin)) {
core.info('Detect the issue comment body is english already, ignore return.')
......@@ -55,6 +56,12 @@ async function run(): Promise<void> {
botLoginName = defaultBotLoginName
}
// support custom bot note message
let customBotMessage = core.getInput('CUSTOM_BOT_NOTE')
if (customBotMessage !== null && customBotMessage.trim() !== "") {
botNote = customBotMessage
}
let octokit = null;
if (botLoginName === null || botLoginName === undefined || botLoginName === '') {
octokit = github.getOctokit(botToken)
......@@ -85,10 +92,10 @@ async function run(): Promise<void> {
core.info(`translate body is: ${translateTmp}`)
if (translateBody.length == 1) {
translateComment = translateBody[0]
translateComment = translateBody[0].trim()
} else if (translateBody.length == 2) {
translateComment = translateBody[0]
translateTitle = translateBody[1]
translateComment = translateBody[0].trim()
translateTitle = translateBody[1].trim()
} else {
core.setFailed(`the translateBody is ${translateTmp}`)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册