refactor(sm): further cleanup #625
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
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_ADMIN_KEY: ${{ secrets.MEILISEARCH_ADMIN_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/bundle | |
- name: Compare with base branch bundle | |
if: success() && github.event.number | |
working-directory: ${{ matrix.working-directory }} | |
run: | | |
if [ -f .next/analyze/base/bundle/__bundle_analysis.json ]; then | |
npx -p nextjs-bundle-analysis compare | |
else | |
echo "Base bundle analysis file not found. Skipping comparison." | |
exit 0 | |
fi | |
- 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 |