Skip to content

reuse the build workflow #2

reuse the build workflow

reuse the build workflow #2

Workflow file for this run

name: Build Application
on:
pull_request:
types: [closed]
branches: [main]
jobs:
build:
if: github.event.pull_request.merged == true
name: "Build Application"
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# Install dependencies with fallback logic
- name: Install dependencies
run: |
# Attempt to install with --frozen-lockfile first
if pnpm install --frozen-lockfile; then
echo "Successfully installed dependencies with frozen lockfile"
else
echo "Failed to install with frozen lockfile, attempting normal install"
# Remove potentially incompatible lockfile
rm -f pnpm-lock.yaml
# Run regular install
pnpm install
fi
# Set up environment variables from GitHub secrets
- name: Set up environment variables
run: |
# Create .env file
touch .env
# Add Convex specific variables
echo "NEXT_PUBLIC_CONVEX_URL=${{ secrets.NEXT_PUBLIC_CONVEX_URL }}" >> .env
echo "CONVEX_DEPLOYMENT=${{ secrets.CONVEX_DEPLOYMENT }}" >> .env
# Add other public and private environment variables
echo "CLERK_SECRET_KEY=${{ secrets.CLERK_SECRET_KEY }}" >> .env
echo "NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=${{ secrets.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY }}" >> .env
# Liveblocks secret key:
echo "LIVE_BLOCK_SECRET_API_KEY=${{secrets.LIVE_BLOCK_SECRET_API_KEY}}" >> .env
- name: Build
run: pnpm build
env:
NEXT_PUBLIC_CONVEX_URL: ${{ secrets.NEXT_PUBLIC_CONVEX_URL }}
# Upload the build artifacts to be used by the deploy job
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-output
path: |
.next
public
package.json
pnpm-lock.yaml
next.config.js
.env