Browse Source

Fix bundle analyzer workflow (#4060)

* try again

* maybe build

* the rest

* add cache back in
main
Dan Abramov 3 years ago
committed by GitHub
parent
commit
d40844b005
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      .github/workflows/nextjs_bundle_analysis.yml

19
.github/workflows/nextjs_bundle_analysis.yml

@ -12,19 +12,16 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with:
path: 'beta'
- name: Set up node - name: Set up node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: "14.x" node-version: "14.x"
- name: Use beta
run: cd beta
- name: Install dependencies - name: Install dependencies
uses: bahmutov/npm-install@v1.6.0 uses: bahmutov/npm-install@v1.6.0
with:
working-directory: 'beta'
- name: Restore next build - name: Restore next build
uses: actions/cache@v2 uses: actions/cache@v2
@ -32,24 +29,26 @@ jobs:
env: env:
cache-name: cache-next-build cache-name: cache-next-build
with: with:
path: .next/cache path: beta/.next/cache
# change this if you prefer a more strict 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 next.js app - name: Build next.js app
# change this if your site requires a custom build command # change this if your site requires a custom build command
run: ./node_modules/.bin/next build run: ./node_modules/.bin/next build
working-directory: beta
# Here's the first place where next-bundle-analysis' own script is used # Here's the first place where next-bundle-analysis' own script is used
# This step pulls the raw bundle stats for the current bundle # This step pulls the raw bundle stats for the current bundle
- name: Analyze bundle - name: Analyze bundle
run: npx -p nextjs-bundle-analysis report run: npx -p nextjs-bundle-analysis report
working-directory: beta
- name: Upload bundle - name: Upload bundle
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: bundle name: bundle
path: .next/analyze/__bundle_analysis.json path: beta/.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
@ -57,7 +56,7 @@ jobs:
with: with:
workflow: nextjs_bundle_analysis.yml workflow: nextjs_bundle_analysis.yml
branch: ${{ github.event.pull_request.base.ref }} branch: ${{ github.event.pull_request.base.ref }}
path: .next/analyze/base path: beta/.next/analyze/base
# And here's the second place - this runs after we have both the current and # 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. # base branch bundle stats, and will compare them to determine what changed.
@ -74,13 +73,13 @@ jobs:
# entry in your package.json file. # entry in your package.json file.
- 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 beta/.next/analyze/base && npx -p 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: | run: |
body=$(cat .next/analyze/__bundle_analysis_comment.txt) body=$(cat beta/.next/analyze/__bundle_analysis_comment.txt)
body="${body//'%'/'%25'}" body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}" body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}" body="${body//$'\r'/'%0D'}"

Loading…
Cancel
Save