From bfdae0d30172789602e4ce38942a557ade03bd3e Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Fri, 13 Nov 2020 00:31:28 +0800 Subject: [PATCH] update action log --- dist/index.js | Bin 675172 -> 675303 bytes dist/index.js.map | Bin 586186 -> 586342 bytes src/main.ts | 41 ++++++++++++++++++----------------------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/dist/index.js b/dist/index.js index b16443ada576fa54dd7f08b4c7c601024dbf5a74..7c8add01425b8e75b59f5752f71db2bd780c828c 100644 GIT binary patch delta 633 zcmZ`$&ubGw6lT-ix4Ws@rBSR0ajJzTs7vEPu`vhnWDhEOl)Bj@(`02c6Lx0BU>6h? z{0GDbD&onT2SHd*9y~~n;@N|W;6LD9Us~)h>M(B(@B7|+-}mO{v)ZrcwTHQpm-4CH z%&m9u#4KhluuFbNCftw2nyj|kQU|f@MIsR4fY+DV!h_wZtc7J8-p_B>tlYYO%~v{! zL@!z!Rf&F;TGh~aV^;8^4R!QBS?1a8f;~gd?K1>l-L+2QaT_W)=fD{6I2Pb{6HeeC z2jWVZ?K$h~_>IuHW|J*0{tulZ6knQf41a&H4&!SV&O1ydOp(*#s|&(#J903Lx#p}` znTDfAYlrAAr8}AtW59)GZP^{MgsU{xEK(B-n}nMisoP7dbh9%|$)v;gL+h(qtJWyK z901?I`9tu-z85Ae2pdmJa0M^Vz=b8DCaqP&BG}bd-Oa?bTTgGjKc4q}o{xI+{XDtn1-ziw=1HD>1E&(!0SHD2 z^o`Onnnfp z@#s#L@C6`>b1FPE7cdtBF41cBcOPeF<$jzdkn^hq%z*#Z4!r?d<`x}k95DocCNI(? zU11K>oq1-v6$kgnNl%_qom(tzm}NfF+Fdk?i*hfcLtX=n7}g)dQS!y0IxLA@Lq#qwP9t6uk2u4k%#bkP>JDdSQu95fcQZn0s@MF MDiHDu5pq2F1I=TC7XSbN diff --git a/dist/index.js.map b/dist/index.js.map index b64daf4773c61f33b475e76cd96dc182057530ca..961f3d829f370ea03816288cd64ee62ec1cbe1de 100644 GIT binary patch delta 752 zcmZutOK1~O6lL0*w5f^IacCLwx~OYcLUA)D;7$?Ti7UZ{U~w&Ox)9WtwAK%Wci_JB&b{ZJ_x5w=m-WuI z=Pz3Mo)D!yAzq?X3Q`)nh1^Zf-O3Lzdf*S;k1IJYi^4VT2;mbWlqN>_)G(!~VSbX* z$*sCJVD7B7vg)=TRywTiqh9M{rQITVr=>n~Sl=sNOL*LJnD1r-x<~jhrD1-I(lLI5 z(urDgdejP6-L8}8#2~w#iQ@7o*Oo6-ONA=O&|nv;jbm@@$pz?Yz)wryz_lVcJVI18 zB1ttND-lIZNxg%_bNgQ^C*WKGUOl?E)pGE{_@#?}-OywuAUqv`MTMOr{}?mz6EHt~~f;5!@WX zJtiEe8}*eS&`eZ~=qv<&D8jg1DM3Hyim9n|QZgiBe_etToDfqr$uF~gy+WMPF@rEg zN>U6GRpVKrNqQz}5LvG+xhc3>r>^%*vyXT(m=pij1P(pUs4|#Vqzk;1xJu+K-8r!GttuVYn?jIlzCK(EvaZS zCe}%Cw71ZWyW%d2Fq(ySC%Ul<`wM)4xNzfAs?&%xc;Ue1!a3)j^Y!!K`%ir$S9GM*z#o19o6bnO-pOJ&!>sJT7;&R*@TaMz)QPPj=1;TlU+bPUVkcgLi zI^ZpA^hJcfBNo(icbaXd*(L#c{APQ{)LU%TfCELF(3c$OKStA3N@g+{DH&{vY1-_v zW?vs?1}{j4q|vTXnME<@K%AqRt*ZXF+c4aNPs#weQGwk!a~D?dYz0pEYZV{_H(dzf zumk(?OBJSp&dqh`333Gc7GMB>IdB|Ds&LV--GdS0zpKFz!51sxn0$pWw)ZFx(P+4RLqrvIR78>rR`Aj{-yhHhIHD9b|egDW-WHp z;syWFBJ3h~z6>J%d;ll+{&Uf9Xv_$N4K}Uw0+!2==m_A>D)iFHpdVef^lOSmO { .payload as webhook.EventPayloads.WebhookPayloadIssueComment const issue_number = issueCommentPayload.issue.number const issue_origin_comment_body = issueCommentPayload.comment.body - core.info(issue_origin_comment_body + "---" + issue_number) - let issue_translate_comment_body = null // detect comment body is english if (detectIsEnglish(issue_origin_comment_body)) { @@ -33,10 +31,13 @@ async function run(): Promise { let octokit = null; const issue_user = issueCommentPayload.comment.user.login let bot_login_name = core.getInput('BOT_LOGIN_NAME') + core.info(`bot_login_name1: ${bot_login_name}`) if (bot_login_name === null) { octokit = github.getOctokit(myToken) const botInfo = await octokit.request('GET /user') + core.info(JSON.stringify(botInfo)) bot_login_name = botInfo.data.login + core.info(`bot_login_name2: ${bot_login_name}`) } if (bot_login_name === issue_user ) { core.info("The issue comment user is bot self, ignore return.") @@ -45,12 +46,14 @@ async function run(): Promise { // translate issue comment body to english - issue_translate_comment_body = await translateCommentBody( + const issue_translate_comment_body = await translateCommentBody( issue_origin_comment_body ) - if (issue_translate_comment_body === null || issue_translate_comment_body === '') { - core.warning("The issue_translate_comment_body is null, ignore return.") + if (issue_translate_comment_body === null + || issue_translate_comment_body === '' + || issue_translate_comment_body === issue_origin_comment_body) { + core.warning("The issue_translate_comment_body is null or same, ignore return.") return } @@ -60,7 +63,7 @@ async function run(): Promise { octokit = github.getOctokit(myToken) } await createComment(issue_number, issue_translate_comment_body, octokit) - core.setOutput('time', new Date().toTimeString()) + core.setOutput('complete time', new Date().toTimeString()) } catch (error) { core.setFailed(error.message) } @@ -69,9 +72,7 @@ async function run(): Promise { function detectIsEnglish(body: string): boolean | true { const lngDetector = new LanguageDetect() const detectResult = lngDetector.detect(body, 1) - for (let i = 0; i < detectResult.length; i++) { - core.info(detectResult[i][0] + detectResult[i][1]) - } + core.info(`detect comment body result is: ${detectResult[0][0]}, sorce: ${detectResult[0][1]}`) return detectResult.length === 1 && detectResult[0][0] === 'english' } @@ -79,7 +80,6 @@ async function translateCommentBody(body: string): Promise { let result = '' await translate(body, {to: 'en'}) .then(res => { - core.info(res.text) result = res.text }) .catch(err => { @@ -91,19 +91,14 @@ async function translateCommentBody(body: string): Promise { async function createComment(issueId: number, body: string, octokit: any): Promise { const {owner, repo} = github.context.repo - core.info(owner + repo) - try { - - core.info("get octokit success!") - await octokit.issues.createComment({ - owner, - repo, - issue_number: issueId, - body - }) - } catch (error) { - core.error(error.message) - } + const issue_url = github.context.payload.issue?.html_url + await octokit.issues.createComment({ + owner, + repo, + issue_number: issueId, + body + }) + core.info(`complete to push translate issue comment: ${body} in ${issue_url}.`) } run() -- GitLab