Skip to content

Upgrade to Next.js 16.3 + migrate to App Router + adopt Cache Components #7708

Upgrade to Next.js 16.3 + migrate to App Router + adopt Cache Components

Upgrade to Next.js 16.3 + migrate to App Router + adopt Cache Components #7708

Workflow file for this run

name: Analyze Bundle
on:
pull_request:
push:
branches:
- main # change this if your default branch is named differently
workflow_dispatch:
permissions: {}
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: yarn
cache-dependency-path: yarn.lock
- name: Restore cached node_modules
uses: actions/cache@v4
with:
path: '**/node_modules'
key: node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Install deps
run: yarn install --frozen-lockfile
- name: Restore next build
uses: actions/cache@v4
id: restore-build-cache
env:
cache-name: cache-next-build
with:
path: .next/cache
# change this if you prefer a more strict cache
key: ${{ runner.os }}-build-${{ env.cache-name }}
- name: Build next.js app
# This project pins the webpack pipeline (see next.config.js): the custom
# webpack config and Sandpack's raw-loader imports aren't Turbopack-ready,
# and Next 16's `next build` defaults to Turbopack. Match the `build`/`analyze`
# npm scripts by forcing `--webpack`.
run: ./node_modules/.bin/next build --webpack
# Measure the current build's bundle sizes (App Router-aware).
# See scripts/analyzeBundle.mjs — reads build-manifest.json + .next/static
# and sums gzipped sizes, since nextjs-bundle-analysis only understands the
# Pages Router and reports 0 B for the App Router.
- name: Analyze bundle
run: node scripts/analyzeBundle.mjs report
- name: Upload bundle
uses: actions/upload-artifact@v4
with:
path: .next/analyze/__bundle_analysis.json
name: bundle_analysis.json
- name: Download base branch bundle stats
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e
if: success() && github.event.number
with:
workflow: analyze.yml
branch: ${{ github.event.pull_request.base.ref }}
name: bundle_analysis.json
path: .next/analyze/base/bundle
# Compare the current build against the base-branch stats downloaded above
# and write the Markdown comment body. Degrades gracefully when the base
# branch has no stats yet (or still has the old format).
- name: Compare with base branch bundle
if: success() && github.event.number
run: node scripts/analyzeBundle.mjs compare
- name: Upload analysis comment
uses: actions/upload-artifact@v4
with:
name: analysis_comment.txt
path: .next/analyze/__bundle_analysis_comment.txt
- name: Save PR number
run: echo ${{ github.event.number }} > ./pr_number
- name: Upload PR number
uses: actions/upload-artifact@v4
with:
name: pr_number
path: ./pr_number
# The actual commenting happens in the other action, matching the guidance in
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/