Skip to content

build: front

build: front #354

# Production CI/CD Pipeline for docs.plus
name: CI-Production
# Triggered on push or pull request to main branch
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
# ============================================================
# UPTIME KUMA - Independent pipeline (no dependencies)
# ============================================================
build-uptime-kuma:
name: πŸ”” Deploy Uptime Kuma
runs-on: prod.docs.plus
if: contains(github.event.head_commit.message, 'build') && contains(github.event.head_commit.message, 'uptime-kuma')
steps:
- name: πŸ“¦ Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
clean: false
- name: πŸš€ Deploy Uptime Kuma
run: make build_uptime_kuma
# ============================================================
# FRONTEND - Build and deploy Next.js app with PM2
# ============================================================
build-front:
name: 🎨 Deploy Frontend
runs-on: prod.docs.plus
if: contains(github.event.head_commit.message, 'build') && contains(github.event.head_commit.message, 'front')
steps:
- name: πŸ“¦ Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
clean: false
- name: πŸ₯Ÿ Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: πŸ“₯ Install dependencies
run: bun install --frozen-lockfile
- name: πŸ” Ensure .env exists
run: |
if [ -f "../../../.env" ]; then
cp ../../../.env packages/webapp/.env
elif [ -f "../../.env" ]; then
cp ../../.env packages/webapp/.env
elif [ -f ".env" ]; then
cp .env packages/webapp/.env
fi
continue-on-error: true
- name: πŸš€ Build & Deploy Frontend
run: make build_front_production
- name: 🩺 Health check
run: |
echo "⏳ Waiting for app to be ready..."
sleep 15
curl -f http://localhost:3001/api/health || (echo "❌ Health check failed" && exit 1)
echo "βœ… Frontend is healthy!"
# ============================================================
# BACKEND - Build and deploy Hocuspocus server with Docker
# ============================================================
build-back:
name: πŸ”§ Deploy Backend
runs-on: prod.docs.plus
if: contains(github.event.head_commit.message, 'build') && contains(github.event.head_commit.message, 'back')
steps:
- name: πŸ“¦ Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
clean: false
- name: πŸ₯Ÿ Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: πŸ“₯ Install dependencies
run: bun install --frozen-lockfile
- name: πŸ” Ensure .env is available
run: |
if [ -f "../../../.env" ]; then
cp ../../../.env packages/hocuspocus.server/.env
elif [ -f "../../.env" ]; then
cp ../../.env packages/hocuspocus.server/.env
elif [ -f ".env" ]; then
cp .env packages/hocuspocus.server/.env
fi
continue-on-error: true
- name: 🐳 Build & Deploy Backend
run: make build_hocuspocus.server_prod
env:
DATABASE_URL: ${{ secrets.STAGE_DATABASE_URL }}
- name: πŸ“Š Check containers
run: |
echo "πŸ” Checking running containers..."
docker ps | grep prod-docsplus || echo "⚠️ Warning: No prod-docsplus containers found"
echo "βœ… Backend deployment completed!"
# ============================================================
# πŸ“– USAGE EXAMPLES
# ============================================================
#
# Trigger specific pipelines by including keywords in commit messages:
#
# 1️⃣ Frontend only:
# git commit -m "Feature: New UI component (build front)"
#
# 2️⃣ Backend only:
# git commit -m "Fix: WebSocket connection (build back)"
#
# 3️⃣ Uptime Kuma only:
# git commit -m "Update monitoring (build uptime-kuma)"
#
# 4️⃣ Frontend + Backend:
# git commit -m "Full deploy (build front back)"
#
# 5️⃣ Everything at once:
# git commit -m "Major release (build front back uptime-kuma)"
#
# Then push to main:
# git push origin main
#
# ============================================================
# πŸ” PIPELINE LOGIC
# ============================================================
#
# - All jobs are independent and self-contained
# - Each job installs Bun and dependencies
# - .env files are preserved during deployment
# - Health checks ensure successful deployments
# - No shared state between jobs (simpler and more reliable)
#
# ============================================================