Skip to content

Commit

Permalink
Delete .github/workflows/nextjs-bundle-analysis2.yml (#2695)
Browse files Browse the repository at this point in the history
* Delete .github/workflows/nextjs-bundle-analysis2.yml

* Update nextjs-bundle-analysis.yml
  • Loading branch information
Dimitri POSTOLOV authored Feb 9, 2024
1 parent d2b21e3 commit bbc9d11
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 156 deletions.
61 changes: 24 additions & 37 deletions .github/workflows/nextjs-bundle-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
name: 'Bundle Analysis: I18n Example (SWR Site)'
name: Bundle Analysis

on:
pull_request:
pull_request_target:
push:
branches: [main, v3, v4-v2]
workflow_dispatch:

defaults:
run:
working-directory: ./

jobs:
analyze:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: ['examples/swr-site', docs]

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
Expand All @@ -27,7 +28,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'
cache: pnpm

- name: Install Dependencies
run: pnpm i
Expand All @@ -40,32 +41,35 @@ jobs:
with:
# if you use a custom build directory, replace all instances of `.next` in this file with your build directory
# ex: if your app builds to `dist`, replace `.next` with `dist`
path: examples/swr-site/.next/cache
path: ${{ matrix.package }}/.next/cache
# change this if you prefer a more strict cache
key: ${{ runner.os }}-build-${{ env.cache-name }}

- name: Build Next.js App
# change this if your site requires a custom build command
run: cd examples/swr-site && ./node_modules/.bin/next build
run: cd ${{ matrix.package }} && ./node_modules/.bin/next build

# Here's the first place where next-bundle-analysis' own script is used
# This step pulls the raw bundle stats for the current bundle
- name: Analyze Bundle
run: cd examples/swr-site && npx -p nextjs-bundle-analysis report
run: cd ${{ matrix.package }} && npx -p nextjs-bundle-analysis report

- name: Upload bundle
uses: actions/upload-artifact@v4
with:
name: bundle
path: examples/swr-site/.next/analyze/__bundle_analysis.json
# Check since we can't use slashes in name
name: bundle-${{ matrix.package == 'docs' && 'docs' || 'swr-site' }}
path: ${{ matrix.package }}/.next/analyze/__bundle_analysis.json

- name: Download Base Branch Bundle Stats
uses: dawidd6/action-download-artifact@v3
if: success() && github.event.number
with:
# Check since we can't use slashes in name
name: bundle-${{ matrix.package == 'docs' && 'docs' || 'swr-site' }}
workflow: nextjs-bundle-analysis.yml
branch: ${{ github.event.pull_request.base.ref }}
path: examples/swr-site/.next/analyze/base
path: ${{ matrix.package }}/.next/analyze/base

# And here's the second place - this runs after we have both the current and
# base branch bundle stats, and will compare them to determine what changed.
Expand All @@ -83,37 +87,20 @@ jobs:
- name: Compare with Base Branch Bundle
if: success() && github.event.number
run:
ls -laR examples/swr-site/.next/analyze/base && cd examples/swr-site
&& npx -p nextjs-bundle-analysis compare
ls -laR ${{ matrix.package }}/.next/analyze/base && cd ${{
matrix.package }} && npx -p nextjs-bundle-analysis compare

- name: Get Comment Body
id: get-comment-body
if: success() && github.event.number
run: |
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "$(cat examples/swr-site/.next/analyze/__bundle_analysis_comment.txt)" >> $GITHUB_OUTPUT
echo "$(cat ${{ matrix.package }}/.next/analyze/__bundle_analysis_comment.txt)" >> $GITHUB_OUTPUT
echo EOF >> $GITHUB_OUTPUT
- name: Find Comment
uses: peter-evans/find-comment@v2
- name: Add comment to PR
uses: marocchino/sticky-pull-request-comment@v2.9.0
if: success() && github.event.number
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: <!-- __NEXTJS_BUNDLE_swr-site

- name: Create Comment
uses: peter-evans/[email protected]
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/[email protected]
if: success() && github.event.number && steps.fc.outputs.comment-id != 0
with:
issue-number: ${{ github.event.number }}
body: ${{ steps.get-comment-body.outputs.body }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
header: 'bundle-analysis-${{ matrix.package }}'
message: ${{ steps.get-comment-body.outputs.body }}
119 changes: 0 additions & 119 deletions .github/workflows/nextjs-bundle-analysis2.yml

This file was deleted.

0 comments on commit bbc9d11

Please sign in to comment.