From 3b2f2380b402478e34fcfbae923ece66919a0b55 Mon Sep 17 00:00:00 2001 From: Innei Date: Mon, 24 Apr 2023 16:55:48 +0800 Subject: [PATCH] ci: try to fix ci (#420) --- .github/workflows/nextjs_bundle_analysis.yml | 57 +++++++++----------- package.json | 6 +++ 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/.github/workflows/nextjs_bundle_analysis.yml b/.github/workflows/nextjs_bundle_analysis.yml index 3674bec9..3903fda5 100644 --- a/.github/workflows/nextjs_bundle_analysis.yml +++ b/.github/workflows/nextjs_bundle_analysis.yml @@ -1,10 +1,15 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + name: "Next.js Bundle Analysis" on: pull_request: push: branches: - - "**" + - main # change this if your default branch is named differently + - master + - dev workflow_dispatch: defaults: @@ -12,36 +17,29 @@ defaults: # change this if your nextjs app does not live at the root of the repo working-directory: ./ +permissions: + contents: read # for checkout repository + actions: read # for fetching base branch bundle stats + pull-requests: write # for comments + jobs: analyze: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up node + - name: Install Node.js uses: actions/setup-node@v3 with: - node-version: "18.x" + node-version: 18 - - name: Cache pnpm modules - uses: actions/cache@v3 - env: - cache-name: cache-pnpm-modules + # If pnpm is used, you need to switch the previous step with the following one. pnpm does not create a package-lock.json + # so the step above will fail to pull dependencies + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install with: - path: ~/.pnpm-store - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} - - uses: actions/cache@v3 - with: - path: | - ${{ github.workspace }}/.next/cache - key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} - restore-keys: | - ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} - - uses: pnpm/action-setup@v2.2.4 - with: - version: 8.x.x + version: 8 run_install: true - name: Restore next build @@ -73,7 +71,6 @@ jobs: - name: Download base branch bundle stats uses: dawidd6/action-download-artifact@v2 - continue-on-error: true if: success() && github.event.number with: workflow: nextjs_bundle_analysis.yml @@ -95,18 +92,16 @@ jobs: # entry in your package.json file. - name: Compare with base branch bundle if: success() && github.event.number - continue-on-error: true run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare - - name: Get comment body + - name: Get Comment Body id: get-comment-body if: success() && github.event.number + # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings run: | - body=$(cat .next/analyze/__bundle_analysis_comment.txt) - body="${body//'%'/'%25'}" - body="${body//$'\n'/'%0A'}" - body="${body//$'\r'/'%0D'}" - echo ::set-output name=body::$body + echo "body<> $GITHUB_OUTPUT + echo "$(cat .next/analyze/__bundle_analysis_comment.txt)" >> $GITHUB_OUTPUT + echo EOF >> $GITHUB_OUTPUT - name: Find Comment uses: peter-evans/find-comment@v2 @@ -117,14 +112,14 @@ jobs: body-includes: "" - name: Create Comment - uses: peter-evans/create-or-update-comment@v3 + uses: peter-evans/create-or-update-comment@v2 if: success() && github.event.number && steps.fc.outputs.comment-id == 0 with: issue-number: ${{ github.event.number }} body: ${{ steps.get-comment-body.outputs.body }} - name: Update Comment - uses: peter-evans/create-or-update-comment@v3 + uses: peter-evans/create-or-update-comment@v2 if: success() && github.event.number && steps.fc.outputs.comment-id != 0 with: issue-number: ${{ github.event.number }} diff --git a/package.json b/package.json index 55a67e63..6596bd18 100644 --- a/package.json +++ b/package.json @@ -197,5 +197,11 @@ "resolutions": { "vitest>vite": "^4.3.1", "rehype-katex>katex": "^0.16.6" + }, + "nextBundleAnalysis": { + "budget": 358400, + "budgetPercentIncreaseRed": 20, + "minimumChangeThreshold": 0, + "showDetails": true } } \ No newline at end of file