-
Notifications
You must be signed in to change notification settings - Fork 77
129 lines (113 loc) · 4.4 KB
/
nextjs_bundle_analysis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: "Next.js Bundle Analysis"
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:
jobs:
analyze:
strategy:
matrix:
app: [shopify-meilisearch, shopify-algolia]
include:
- app: shopify-meilisearch
working-directory: ./starters/shopify-meilisearch
- app: shopify-algolia
working-directory: ./starters/shopify-algolia
environment: Production
name: Analyze (${{ matrix.app }})
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ matrix.app }}-${{ github.ref }}
cancel-in-progress: true
env:
SKIP_ENV_VALIDATION: true
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
SHOPIFY_STOREFRONT_ACCESS_TOKEN: ${{ secrets.SHOPIFY_STOREFRONT_ACCESS_TOKEN }}
SHOPIFY_ADMIN_ACCESS_TOKEN: ${{ secrets.SHOPIFY_ADMIN_ACCESS_TOKEN }}
SHOPIFY_STORE_DOMAIN: ${{ secrets.SHOPIFY_STORE_DOMAIN }}
MEILISEARCH_MASTER_KEY: ${{ secrets.MEILISEARCH_MASTER_KEY }}
MEILISEARCH_HOST: ${{ secrets.MEILISEARCH_HOST }}
SHOPIFY_APP_API_SECRET_KEY: ${{ secrets.SHOPIFY_APP_API_SECRET_KEY }}
REPLICATE_API_KEY: ${{ secrets.REPLICATE_API_KEY }}
steps:
- uses: actions/checkout@v4
- run: echo "node_version=$(cat .github/nodejs.version)" >> $GITHUB_ENV
- name: "use node ${{ env.node_version }}"
uses: actions/setup-node@v3
with:
node-version: "${{ env.node_version }}"
- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ matrix.app }}-bundle-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline
working-directory: ${{ matrix.working-directory }}
- name: Restore next build
uses: actions/cache@v3
id: restore-build-cache
env:
cache-name: cache-next-build-${{ matrix.app }}
with:
path: ${{ matrix.working-directory }}/.next/cache
key: ${{ runner.os }}-build-${{ env.cache-name }}
- name: Build next.js app
env:
SKIP_BUILD_PRODUCT_REDIRECTS: 1
run: cd ${{ matrix.working-directory }} && yarn build && cd -
- name: Analyze bundle
working-directory: ${{ matrix.working-directory }}
run: node report-bundle-size.js
- name: Upload bundle
uses: actions/upload-artifact@v3
with:
name: bundle-${{ matrix.app }}
path: ${{ matrix.working-directory }}/.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 }}
name: bundle-${{ matrix.app }}
path: ${{ matrix.working-directory }}/.next/analyze/base
- name: Compare with base branch bundle
if: success() && github.event.number
working-directory: ${{ matrix.working-directory }}
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
working-directory: ${{ matrix.working-directory }}
run: |
body=$(cat .next/analyze/__bundle_analysis_comment.txt)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "::set-output name=body::$body"
- name: Find Comment
uses: peter-evans/find-comment@v2
if: success() && github.event.number
id: fc
with:
issue-number: ${{ github.event.number }}
comment-author: "github-actions[bot]"
body-includes: "<!-- NEXTJS_BUNDLE_${{ matrix.app }} -->"
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v3
if: success() && github.event.number
with:
issue-number: ${{ github.event.number }}
body: |
<!-- NEXTJS_BUNDLE_${{ matrix.app }} -->
# Next.js Bundle Analysis (${{ matrix.app }})
${{ steps.get-comment-body.outputs.body }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace