From bbb46d851ecde3fe730bc2fc98c4bcd04cc2aaa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=99=9A=E6=97=A0?= Date: Tue, 23 Mar 2021 11:04:05 +0800 Subject: [PATCH] chore: action --- .github/workflows/comment.yml | 4 ++-- script/comment.js | 39 +++++++++++++++++------------------ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml index d6f86fc..fa2c305 100644 --- a/.github/workflows/comment.yml +++ b/.github/workflows/comment.yml @@ -11,7 +11,7 @@ jobs: - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJSON(github) }} - ISSUEHOST: ${{ secrets.ISSUEHOST }} + COMMENTHOST: ${{ secrets.COMMENTHOST }} run: | yarn - node ./script/issue.js + node ./script/comment.js diff --git a/script/comment.js b/script/comment.js index e95444e..84f0838 100644 --- a/script/comment.js +++ b/script/comment.js @@ -1,24 +1,23 @@ const axios = require("axios"); const { - event: { issue, action }, + event: { comment }, } = JSON.parse(process.env.GITHUB_CONTEXT); -const { author_association, body, title, number } = issue; -const host = process.env.ISSUEHOST; +const { + body, + updated_at, + html_url, + id, + user: { avatar_url, login }, + issue: { number }, +} = comment; +const host = process.env.COMMENTHOST; -console.log(JSON.parse(process.env.GITHUB_CONTEXT);); - -// if (author_association === "OWNER") { -// if (action === "edited") { -// axios.put(host, { -// name: title, -// issueId: number, -// content: body, -// }); -// } else if (action === "opened") { -// axios.post(host, { -// name: title, -// issueId: number, -// content: body, -// }); -// } -// } +axios.post(host, { + issueId: number, + commentId: id, + htmlUrl: html_url, + userName: login, + avatarUrl: avatar_url, + content: body, + updatedAt: updated_at, +});