From 2f11a455e0a861237d51758cb37293b58f9d029a Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 28 Jun 2024 22:58:34 +0800 Subject: [PATCH] ci: correct PR number retrieval to fix size-report action (#11223) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 三咲智子 Kevin Deng --- .github/workflows/size-data.yml | 10 ++++++++++ .github/workflows/size-report.yml | 31 ++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/.github/workflows/size-data.yml b/.github/workflows/size-data.yml index 767114e0d9f..a702d0fef90 100644 --- a/.github/workflows/size-data.yml +++ b/.github/workflows/size-data.yml @@ -41,3 +41,13 @@ jobs: with: name: size-data path: temp/size + + - name: Save PR number + if: ${{github.event_name == 'pull_request'}} + run: echo ${{ github.event.number }} > ./pr.txt + + - uses: actions/upload-artifact@v4 + if: ${{github.event_name == 'pull_request'}} + with: + name: pr-number + path: pr.txt diff --git a/.github/workflows/size-report.yml b/.github/workflows/size-report.yml index eb0d7d4fd83..9c0efadf5ae 100644 --- a/.github/workflows/size-report.yml +++ b/.github/workflows/size-report.yml @@ -35,6 +35,19 @@ jobs: - name: Install dependencies run: pnpm install + - name: Download PR number + uses: dawidd6/action-download-artifact@v3 + with: + name: pr-number + run_id: ${{ github.event.workflow_run.id }} + path: /tmp/pr-number + + - name: Read PR Number + id: pr-number + uses: juliangruber/read-file-action@v1 + with: + path: /tmp/pr-number/pr.txt + - name: Download Size Data uses: dawidd6/action-download-artifact@v6 with: @@ -55,10 +68,18 @@ jobs: - name: Prepare report run: pnpm tsx scripts/size-report.ts > size-report.md + - name: Read Size Report + id: size-report + uses: juliangruber/read-file-action@v1 + with: + path: ./size-report.md + - name: Create Comment - uses: thollander/actions-comment-pull-request@v2.5.0 + uses: actions-cool/maintain-one-comment@v3 with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - filePath: size-report.md - pr_number: ${{ github.event.workflow_run.pull_requests[0].number }} - comment_tag: VUE_CORE_SIZE + token: ${{ secrets.GITHUB_TOKEN }} + number: ${{ steps.pr-number.outputs.content }} + body: | + ${{ steps.size-report.outputs.content }} + + body-include: ''