浏览代码

CI: Fix report-size.yml execution (#25625)

Marco Fugaro 2 年之前
父节点
当前提交
51f5968dc7
共有 2 个文件被更改,包括 8 次插入3 次删除
  1. 1 1
      .github/workflows/read-size.yml
  2. 7 2
      .github/workflows/report-size.yml

+ 1 - 1
.github/workflows/read-size.yml

@@ -42,7 +42,7 @@ jobs:
           TREESHAKEN_GZIP=$(stat --format=%s test/treeshake/index.bundle.min.js.gz)
           TREESHAKEN_GZIP=$(stat --format=%s test/treeshake/index.bundle.min.js.gz)
 
 
           # write the output in a json file to upload it as artifact
           # write the output in a json file to upload it as artifact
-          node -pe "JSON.stringify({ filesize: $FILESIZE, gzip: $FILESIZE_GZIP, treeshaken: $TREESHAKEN, treeshakenGzip: $TREESHAKEN_GZIP })" > sizes.json
+          node -pe "JSON.stringify({ filesize: $FILESIZE, gzip: $FILESIZE_GZIP, treeshaken: $TREESHAKEN, treeshakenGzip: $TREESHAKEN_GZIP, pr: ${{ github.event.pull_request.number }} })" > sizes.json
       - name: Upload artifact
       - name: Upload artifact
         uses: actions/upload-artifact@v3
         uses: actions/upload-artifact@v3
         with:
         with:

+ 7 - 2
.github/workflows/report-size.yml

@@ -21,6 +21,11 @@ jobs:
     if: github.event.workflow_run.event == 'pull_request' &&
     if: github.event.workflow_run.event == 'pull_request' &&
       github.event.workflow_run.conclusion == 'success'
       github.event.workflow_run.conclusion == 'success'
     steps:
     steps:
+      - name: Log GitHub context
+        env:
+          GITHUB_CONTEXT: ${{ toJson(github) }}
+        run: echo "$GITHUB_CONTEXT"
+
       # Using actions/download-artifact doesn't work here
       # Using actions/download-artifact doesn't work here
       # https://github.com/actions/download-artifact/issues/60
       # https://github.com/actions/download-artifact/issues/60
       - name: Download artifact
       - name: Download artifact
@@ -101,13 +106,13 @@ jobs:
         uses: peter-evans/find-comment@v2
         uses: peter-evans/find-comment@v2
         id: find-comment
         id: find-comment
         with:
         with:
-          issue-number: ${{ github.event.workflow_run.pull_requests[0].number }}
+          issue-number: ${{ fromJSON(steps.download-artifact.outputs.result).pr }}
           comment-author: 'github-actions[bot]'
           comment-author: 'github-actions[bot]'
           body-includes: Bundle size
           body-includes: Bundle size
       - name: Comment on PR
       - name: Comment on PR
         uses: peter-evans/create-or-update-comment@v2
         uses: peter-evans/create-or-update-comment@v2
         with:
         with:
-          issue-number: ${{ github.event.workflow_run.pull_requests[0].number }}
+          issue-number: ${{ fromJSON(steps.download-artifact.outputs.result).pr }}
           comment-id: ${{ steps.find-comment.outputs.comment-id }}
           comment-id: ${{ steps.find-comment.outputs.comment-id }}
           edit-mode: replace
           edit-mode: replace
           body: |
           body: |