Analytics: add Spindl #107
Workflow file for this run
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
# Copyright (c) HashiCorp, Inc. | |
# SPDX-License-Identifier: MPL-2.0 | |
name: 'Next.js Bundle Analysis' | |
on: | |
pull_request: | |
push: | |
branches: | |
- dev | |
permissions: | |
contents: read # for checkout repository | |
actions: read # for fetching base branch bundle stats | |
pull-requests: write # for comments | |
jobs: | |
analyze: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install dependencies | |
uses: ./.github/workflows/yarn | |
- name: Build next.js app | |
uses: ./.github/workflows/build | |
with: | |
secrets: ${{ toJSON(secrets) }} | |
- name: Analyze bundle | |
run: npx -p nextjs-bundle-analysis report | |
- name: Upload bundle | |
uses: actions/upload-artifact@v3 | |
with: | |
name: bundle | |
path: .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: .next/analyze/base | |
- name: Compare with base branch bundle | |
if: success() && github.event.number | |
run: 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: | | |
echo "body<<EOF" >> $GITHUB_OUTPUT | |
echo "$(cat .next/analyze/__bundle_analysis_comment.txt)" >> $GITHUB_OUTPUT | |
echo EOF >> $GITHUB_OUTPUT | |
- name: Comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: next-bundle-analysis | |
message: ${{ steps.get-comment-body.outputs.body }} |