Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sureness
Issues Translate Action
提交
b0527a12
I
Issues Translate Action
项目概览
sureness
/
Issues Translate Action
通知
4
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Issues Translate Action
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
b0527a12
编写于
3月 21, 2021
作者:
sinat_25235033
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support bot custom note message
上级
f3478beb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
16 addition
and
6 deletion
+16
-6
.github/workflows/action-test.yml
.github/workflows/action-test.yml
+2
-1
action.yml
action.yml
+2
-0
dist/index.js
dist/index.js
+0
-0
dist/index.js.map
dist/index.js.map
+0
-0
src/main.ts
src/main.ts
+12
-5
未找到文件。
.github/workflows/action-test.yml
浏览文件 @
b0527a12
...
...
@@ -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. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
action.yml
浏览文件 @
b0527a12
...
...
@@ -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'
dist/index.js
浏览文件 @
b0527a12
此差异由.gitattributes 抑制。
dist/index.js.map
浏览文件 @
b0527a12
此差异由.gitattributes 抑制。
src/main.ts
浏览文件 @
b0527a12
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录