mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
ci: fix nextjs bundle analysis
This commit is contained in:
38
.github/workflows/nextjs-bundle-analysis.yml
vendored
38
.github/workflows/nextjs-bundle-analysis.yml
vendored
@@ -4,14 +4,18 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- 'main'
|
- 'main'
|
||||||
paths:
|
paths:
|
||||||
- 'apps/website'
|
- 'apps/website/**'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- 'apps/website'
|
- 'apps/website/**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
working-directory: ./apps/website
|
working-directory: apps/website
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
actions: read
|
||||||
|
pull-requests: write
|
||||||
jobs:
|
jobs:
|
||||||
analyze:
|
analyze:
|
||||||
name: Analyze
|
name: Analyze
|
||||||
@@ -34,45 +38,43 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
cache-name: cache-next-build
|
cache-name: cache-next-build
|
||||||
with:
|
with:
|
||||||
# if you use a custom build directory, replace all instances of `.next` in this file with your build directory
|
path: apps/website/.next/cache
|
||||||
# ex: if your app builds to `dist`, replace `.next` with `dist`
|
|
||||||
path: .next/cache
|
|
||||||
# change this if you prefer a more strict cache
|
|
||||||
key: ${{ runner.os }}-build-${{ env.cache-name }}
|
key: ${{ runner.os }}-build-${{ env.cache-name }}
|
||||||
|
|
||||||
- name: Build website
|
- name: Build website
|
||||||
run: yarn workspace @discordjs/website run build:prod
|
run: yarn workspace @discordjs/website run build:prod
|
||||||
|
|
||||||
- name: Analyze bundle
|
- name: Analyze bundle
|
||||||
run: npx -p nextjs-bundle-analysis report
|
run: npx -yes -p github:hashicorp/nextjs-bundle-analysis report
|
||||||
|
|
||||||
- name: Upload bundle
|
- name: Upload bundle
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: bundle
|
name: bundle
|
||||||
path: .next/analyze/__bundle_analysis.json
|
path: apps/website/.next/analyze/__bundle_analysis.json
|
||||||
|
|
||||||
- name: Download base branch bundle stats
|
- name: Download base branch bundle stats
|
||||||
uses: dawidd6/action-download-artifact@v2
|
uses: dawidd6/action-download-artifact@v2
|
||||||
if: success() && github.event.number
|
if: success() && github.event.number
|
||||||
with:
|
with:
|
||||||
workflow: nextjs-bundle-analysis.yml
|
workflow: nextjs-bundle-analysis.yml
|
||||||
branch: ${{ github.event.pull_request.base.ref }}
|
commit: ${{ github.event.pull_request.base.sha }}
|
||||||
path: .next/analyze/base
|
path: apps/website/.next/analyze/base
|
||||||
|
|
||||||
- name: Compare with base branch bundle
|
- name: Compare with base branch bundle
|
||||||
if: success() && github.event.number
|
if: success() && github.event.number
|
||||||
run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare
|
run: ls -laR .next/analyze/base && npx -yes -p github:hashicorp/nextjs-bundle-analysis compare
|
||||||
|
|
||||||
- name: Get comment body
|
- name: Get comment body
|
||||||
id: get-comment-body
|
id: get-comment-body
|
||||||
if: success() && github.event.number
|
if: success() && github.event.number
|
||||||
run: |
|
uses: actions/github-script@v6
|
||||||
body=$(cat .next/analyze/__bundle_analysis_comment.txt)
|
with:
|
||||||
body="${body//'%'/'%25'}"
|
result-encoding: string
|
||||||
body="${body//$'\n'/'%0A'}"
|
script: |
|
||||||
body="${body//$'\r'/'%0D'}"
|
const fs = require('fs');
|
||||||
echo ::set-output name=body::$body
|
const comment = fs.readFileSync('.next/analyze/__bundle_analysis_comment.txt', 'utf8');
|
||||||
|
core.setOutput('body', comment);
|
||||||
|
|
||||||
- name: Find Comment
|
- name: Find Comment
|
||||||
uses: peter-evans/find-comment@v2
|
uses: peter-evans/find-comment@v2
|
||||||
|
|||||||
@@ -99,5 +99,10 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.9.0"
|
"node": ">=16.9.0"
|
||||||
|
},
|
||||||
|
"nextBundleAnalysis": {
|
||||||
|
"budget": 358400,
|
||||||
|
"budgetPercentIncreaseRed": 20,
|
||||||
|
"showDetails": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user