Skip to content

Merge pull request #1516 from drivly/devin/1744784304-fix-pnpm-instal… #3141

Merge pull request #1516 from drivly/devin/1744784304-fix-pnpm-instal…

Merge pull request #1516 from drivly/devin/1744784304-fix-pnpm-instal… #3141

Workflow file for this run

name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Run Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- uses: pnpm/action-setup@v2
with:
version: 10.x
- uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
env:
PAYLOAD_SECRET: ${{ secrets.PAYLOAD_SECRET || 'dev-secret-for-build-only' }}
DATABASE_URI: ${{ secrets.DATABASE_URI || 'mongodb://localhost:27017/payload-cms' }}
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY || 'resend-key-placeholder' }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY || 'sk_test_placeholder' }}
# Bundle analysis steps
- name: Restore next build
uses: actions/cache@v4
id: restore-build-cache
env:
cache-name: cache-next-build
with:
path: .next/cache
# If you use a different build directory, change this path
key: ${{ runner.os }}-build-${{ env.cache-name }}
- name: Analyze bundle
run: npx -p nextjs-bundle-analysis report
- name: Upload bundle
uses: actions/upload-artifact@v4
with:
name: bundle
path: .next/analyze/__bundle_analysis.json
- name: Download base branch bundle stats
uses: dawidd6/action-download-artifact@v6
if: success() && github.event.number
with:
workflow: build.yml
branch: ${{ github.event.pull_request.base.ref }}
path: .next/analyze/base/bundle
if_no_artifact_found: warn
- name: Check if base branch bundle exists
id: check-base-bundle
if: success() && github.event.number
run: |
if [ -d ".next/analyze/base/bundle" ] && [ "$(ls -A .next/analyze/base/bundle 2>/dev/null)" ]; then
echo "base_bundle_exists=true" >> $GITHUB_OUTPUT
else
echo "base_bundle_exists=false" >> $GITHUB_OUTPUT
fi
- name: Compare with base branch bundle
if: success() && github.event.number && steps.check-base-bundle.outputs.base_bundle_exists == 'true'
run: |
if [ -f ".next/analyze/base/bundle/__bundle_analysis.json" ]; then
npx -p nextjs-bundle-analysis compare || echo "Bundle comparison failed, but continuing build"
else
echo "No base bundle analysis file found. Skipping comparison."
fi
continue-on-error: true
- name: Get Comment
id: get-comment
if: success() && github.event.number
run: |
if [ -f .next/analyze/__bundle_analysis_comment.txt ]; then
echo "comment=$(cat .next/analyze/__bundle_analysis_comment.txt)" >> $GITHUB_OUTPUT
fi
- name: Comment
uses: marocchino/sticky-pull-request-comment@v2
if: success() && github.event.number && steps.get-comment.outputs.comment
with:
header: next-bundle-analysis
message: ${{ steps.get-comment.outputs.comment }}