From 46136b5632a6dfd8d2d6a874c4fe197d8dd05b36 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Wed, 6 Mar 2024 18:23:06 +0000 Subject: [PATCH] ci(e2e): avoid commenting on PRs in CI GitHub Actions can't comment on PRs, if the PR is made from a forked repo, as [the github token won't have write permissions][1]. However, we can instead use GitHub Actions' [Adding a Job Summary][2] feature, which prints some custom output for each job. [1]: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs#changing-the-permissions-in-a-forked-repository [2]: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary Fix: e0448a7b7be4fcad775f9dd0292f49845c84836c --- .github/workflows/e2e.yml | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index fe590dd10..81e58f6aa 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -15,7 +15,6 @@ on: permissions: contents: read - pull-requests: write env: # For PRs and MergeQueues, the target commit is used, and for push events, github.event.previous is used. @@ -56,8 +55,8 @@ jobs: # just perform install runTests: false - - name: Build - if: ${{ steps.cache-snapshot.outputs.cache-hit != 'true' && github.event_name == 'pull_request' }} + - name: Calculate bundle size + if: ${{ steps.cache-snapshot.outputs.cache-hit != 'true'}} run: | pnpm run build:viz mkdir -p cypress/snapshots/stats/base @@ -107,26 +106,14 @@ jobs: with: runTests: false - - name: Build - id: size - if: ${{ github.event_name == 'pull_request' && matrix.containers == 1 }} + - name: Output size diff + if: ${{ matrix.containers == 1 }} run: | pnpm run build:viz mv stats cypress/snapshots/stats/head - { - echo 'size_diff<> "$GITHUB_OUTPUT" - - # Size diff only needs to be posted from one job, on PRs. - - name: Comment PR size difference - if: ${{ github.event_name == 'pull_request' && matrix.containers == 1 }} - uses: thollander/actions-comment-pull-request@v2 - with: - message: | - ${{ steps.size.outputs.size_diff }} - comment_tag: size-diff + echo '## Bundle size difference' >> "$GITHUB_STEP_SUMMARY" + echo '' >> "$GITHUB_STEP_SUMMARY" + npx tsx scripts/size.ts >> "$GITHUB_STEP_SUMMARY" # Install NPM dependencies, cache them correctly # and run all Cypress tests