From de80c77ff17dadfc307251ccb2a989ffe2dfb167 Mon Sep 17 00:00:00 2001 From: hanyugeon Date: Fri, 31 May 2024 01:57:22 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20pr=20comment=20=EC=9E=91=EC=84=B1=20?= =?UTF-8?q?=EB=B0=8F=20=EC=88=98=EC=A0=95=20=EB=B0=A9=EC=8B=9D=20=EA=B5=90?= =?UTF-8?q?=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/get-score-comments/action.js | 34 ++++++++++---------- .github/workflows/lighthouse.yml | 23 ++++++++++++- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/.github/actions/get-score-comments/action.js b/.github/actions/get-score-comments/action.js index 21ffc1c5..cd2a15d6 100644 --- a/.github/actions/get-score-comments/action.js +++ b/.github/actions/get-score-comments/action.js @@ -1,4 +1,4 @@ -// const core = require('@actions/core'); +const core = require('@actions/core'); console.log('꼽냐?'); try { @@ -97,23 +97,23 @@ try { )}${unit} |\n`; }); - // // comments 내보내기 - // core.setOutput('comments', comments); + // comments 내보내기 + core.setOutput('comments', comments); - // Comment 작성 - if (comments && context.issue.number) { - const issue_number = context.issue.number; - const repo = context.repo.repo; - const owner = context.repo.owner; - github.issues.createComment({ - owner, - repo, - issue_number, - body: comments, - }); - } else { - console.log('No PR COMMENT!'); - } + // // Comment 작성 + // if (comments && context.issue.number) { + // const issue_number = context.issue.number; + // const repo = context.repo.repo; + // const owner = context.repo.owner; + // github.issues.createComment({ + // owner, + // repo, + // issue_number, + // body: comments, + // }); + // } else { + // console.log('No PR COMMENT!'); + // } } catch (error) { console.error(error); } diff --git a/.github/workflows/lighthouse.yml b/.github/workflows/lighthouse.yml index 9edcadea..cd6a7cfa 100644 --- a/.github/workflows/lighthouse.yml +++ b/.github/workflows/lighthouse.yml @@ -1,6 +1,9 @@ name: LightHouse CI -on: [push] +on: + pull_request: + branches: + - main jobs: lhci: @@ -32,3 +35,21 @@ jobs: - name: Get Score Comments id: get-score-comments uses: ./.github/actions/get-score-comments + + - name: Find Comment + if: github.event_name == 'pull_request' + uses: peter-evans/find-comment@v2 + id: find_comment + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: ⚡️ Lighthouse Average Scores Across Reports + + - name: Create or update comment + if: github.event_name == 'pull_request' + uses: peter-evans/create-or-update-comment@v2 + with: + comment-id: ${{ steps.find_comment.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: ${{ steps.get-score-comments.outputs.comments }} + edit-mode: replace