build: front #354
This file contains hidden or 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
# 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) | |
# | |
# ============================================================ |