-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from Southclaws/next-bundle-analysis
try nextjs bundle analysis
- Loading branch information
Showing
2 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
name: "Next.js Bundle Analysis" | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
actions: read | ||
pull-requests: write | ||
|
||
jobs: | ||
analyze: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
uses: bahmutov/npm-install@v1 | ||
with: | ||
working-directory: web | ||
|
||
- name: Restore next build | ||
uses: actions/cache@v3 | ||
id: restore-build-cache | ||
env: | ||
cache-name: cache-next-build | ||
with: | ||
path: web/.next/cache | ||
key: ${{ runner.os }}-build-${{ env.cache-name }} | ||
|
||
- name: Build next.js app | ||
run: | | ||
cd web | ||
./node_modules/.bin/next experimental-compile | ||
- name: Analyze bundle | ||
run: | | ||
cd web | ||
npx -p nextjs-bundle-analysis report | ||
- name: Upload bundle | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bundle | ||
path: web/.next/analyze/__bundle_analysis.json | ||
|
||
- name: Download base branch bundle stats | ||
uses: dawidd6/action-download-artifact@v2 | ||
if: success() && github.event.number | ||
with: | ||
workflow: nextjs_bundle_analysis.yml | ||
branch: ${{ github.event.pull_request.base.ref }} | ||
path: web/.next/analyze/base | ||
|
||
- name: Compare with base branch bundle | ||
if: success() && github.event.number | ||
run: | | ||
cd web | ||
ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare | ||
- 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: | | ||
cd web | ||
echo "body<<EOF" >> $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 | ||
if: success() && github.event.number | ||
id: fc | ||
with: | ||
issue-number: ${{ github.event.number }} | ||
body-includes: "<!-- __NEXTJS_BUNDLE -->" | ||
|
||
- name: Create Comment | ||
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@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 }} | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
edit-mode: replace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79ffa62
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
storyden-homepage – ./home
storyden-homepage-southclaws.vercel.app
www.storyden.org
storyden-homepage-git-main-southclaws.vercel.app
storyden.org
storyden-homepage.vercel.app
79ffa62
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
storyden – ./web
storyden.vercel.app
www.makeroom.club
storyden-git-main-southclaws.vercel.app
storyden-southclaws.vercel.app
makeroom.club
demo.storyden.org