diff --git a/.github/workflows/dist-files-size-diff-comment.yaml b/.github/workflows/dist-files-size-diff-comment.yaml new file mode 100644 index 0000000000..d43f79c0a7 --- /dev/null +++ b/.github/workflows/dist-files-size-diff-comment.yaml @@ -0,0 +1,22 @@ +name: Dist Files Size Diff (Comment) + +on: + workflow_run: + workflows: ["Dist Files Size Diff"] + types: + - completed + +jobs: + dist-files-size-diff: + runs-on: ubuntu-latest + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: dist-size-${{ github.event.number }} + + - name: Comment on the pull request (if success) + if: ${{ always() && steps.diff.conclusion == 'success' }} + uses: marocchino/sticky-pull-request-comment@v2 + with: + path: ./dist-size.md diff --git a/.github/workflows/dist-files-size-diff.yaml b/.github/workflows/dist-files-size-diff.yaml index a8bc3d4311..a28eccf4cb 100644 --- a/.github/workflows/dist-files-size-diff.yaml +++ b/.github/workflows/dist-files-size-diff.yaml @@ -2,6 +2,7 @@ name: Dist Files Size Diff on: pull_request: + types: [opened, synchronize] paths: - 'src/*/assets/dist/**' - 'src/*/src/Bridge/*/assets/dist/**' @@ -9,19 +10,12 @@ on: jobs: dist-files-size-diff: runs-on: ubuntu-latest - permissions: - pull-requests: write # for marocchino/sticky-pull-request-comment@v2 steps: - name: Configure git run: | git config --global user.email "" git config --global user.name "github-action[bot]" - - uses: marocchino/sticky-pull-request-comment@v2 - with: - message: | - ⏳ The dist files size difference is being calculated... - - uses: actions/checkout@v4 with: ref: ${{ github.base_ref }} @@ -59,19 +53,16 @@ jobs: with: result-encoding: string script: | + import * as fs from 'fs' const { main } = await import('${{ github.workspace }}/.github/generate-dist-files-size-diff.mjs') - return await main() + const diff = await main() + console.log(diff); - - name: Comment on the pull request (if any failure) - if: ${{ failure() }} - uses: marocchino/sticky-pull-request-comment@v2 - with: - message: | - ❌ The dist files size difference could not be calculated. Please check the logs for more details. + fs.writeFileSync(process.env.GITHUB_WORKSPACE + '/dist-size.md', diff) - - name: Comment on the pull request (if success) - if: ${{ always() && steps.diff.conclusion == 'success' }} - uses: marocchino/sticky-pull-request-comment@v2 + - name: Upload the diff + uses: actions/upload-artifact@v4 with: - message: ${{ steps.diff.outputs.result }} + name: dist-size-${{ github.event.number }} + path: ./dist-size.md