docs
Deployment

Deployment

Complete guide to deploying the portfolio with multi-version support to GitHub Pages.

🚀 Multi-Version Deployment System

This portfolio uses a custom deployment system that supports hosting multiple versions simultaneously:

  • V2 (Current) at root: https://abishek-maharajan.online
  • V1 (Legacy) at /v1: https://abishek-maharajan.online/v1

Quick Deploy

Windows (PowerShell):

.\scripts\deploy-composite.ps1

Linux/Mac (Bash):

chmod +x scripts/deploy-composite.sh
./scripts/deploy-composite.sh

What It Does

The deployment script automatically:

  1. Builds V1 with basePath: '/v1' configuration
  2. Builds V2 at root with default paths
  3. Merges both builds into a single deployment artifact
  4. Creates CNAME file for custom domain
  5. Deploys to gh-pages branch with force push
  6. Returns you to your original branch

Duration: ~8-10 minutes total


Pre-Deployment Verification

Before deploying, run the local verification script:

.\scripts\verify-local.ps1

This checks:

  • ✅ Dev server is running
  • ✅ All docs pages load correctly
  • ✅ Test suite passes (45/45 tests)
  • ✅ TypeScript compiles without errors
  • ✅ Production build succeeds
  • ✅ Git status is clean

GitHub Pages Setup

1. Enable GitHub Pages

  1. Go to repository SettingsPages
  2. Set source to gh-pages branch
  3. Set folder to / (root)
  4. Click Save

2. Configure Custom Domain

The deployment script automatically creates a CNAME file with:

abishek-maharajan.online

DNS Configuration:

Type: A
Name: @
Value: 185.199.108.153
       185.199.109.153
       185.199.110.153
       185.199.111.153

Type: CNAME
Name: www
Value: tentaciopro.github.io

3. Enable HTTPS

GitHub Pages automatically provisions SSL certificates for custom domains.


Deployment Architecture

GitHub Repository (feat/factory-floor)

    Deployment Script

    ┌──────┴──────┐
    ↓             ↓
V2 Build      V1 Build
(root)        (basePath: /v1)
    ↓             ↓
    └──────┬──────┘

    Merged Artifact
    ├── index.html (V2)
    ├── _next/ (V2 assets)
    ├── v1/
    │   ├── index.html (V1)
    │   └── _next/ (V1 assets)
    ├── CNAME
    └── .nojekyll

    gh-pages Branch

    GitHub Pages

  abishek-maharajan.online

Build Configuration

V2 (Current) - Root Deployment

File: apps/web/next.config.mjs

const nextConfig = {
  output: "export",
  basePath: "",                  // Root directory
  assetPrefix: "",               // Default assets path
  trailingSlash: true,
  images: { unoptimized: true },
}

V1 (Legacy) - Subdirectory Deployment

The deployment script automatically modifies V1's config:

const nextConfig = {
  output: "export",
  basePath: "/v1",               // Subdirectory
  assetPrefix: "/v1",            // Prefixed assets
  trailingSlash: true,
  images: { unoptimized: true },
}

Build Output

V2 Directory: apps/web/out
V1 Directory: out (from release/may-2025-v1 branch)

Merged Output:

  • 245 files total
  • ~51 MB deployed
  • Static HTML, CSS, JS
  • Optimized assets

Deployment Scripts

Main Deployment Script

Location: scripts/deploy-composite.ps1 (Windows) / scripts/deploy-composite.sh (Linux/Mac)

Features:

  • Automatic branch switching
  • Dual build process (V1 + V2)
  • Config modification for V1
  • Artifact merging
  • Git worktree deployment
  • Force push handling
  • Automatic cleanup

Verification Script

Location: scripts/verify-deployment.ps1

Tests both deployed versions:

.\scripts\verify-deployment.ps1

Checks:

  • V2 accessibility at root
  • V1 accessibility at /v1
  • HTTP status codes
  • Response times

Local Verification

Location: scripts/verify-local.ps1

Pre-deployment checks:

.\scripts\verify-local.ps1

Troubleshooting

Common Issues

Issue: Sidebar not showing in docs

Solution: Ensure head in theme.config.jsx is a function:

head: () => (<>...</>)  // ✅ Correct
head: (<>...</>)        // ❌ Wrong

Issue: CSP blocking Google Fonts

Solution: Update CSP in next.config.mjs:

"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
"font-src 'self' data: https://fonts.gstatic.com",

Issue: Assets 404 on GitHub Pages

Solution:

  • Check basePath configuration
  • Verify CNAME file exists
  • Ensure custom domain is configured in GitHub Settings

Issue: Deployment fails with "rejected" error

Solution: The script uses --force push. If it still fails:

git checkout gh-pages
git pull origin gh-pages
git checkout feat/factory-floor
.\scripts\deploy-composite.ps1

Deployment Checklist

Pre-Deployment

  • Run tests: pnpm test:run
  • Run linter: pnpm lint
  • Format code: pnpm format
  • Build locally: pnpm build
  • Test build: pnpm start
  • Check for console errors
  • Verify responsive design

Post-Deployment

  • Verify site loads correctly
  • Check all links work
  • Test navigation
  • Verify images load
  • Check video playback
  • Test on mobile devices
  • Run Lighthouse audit
  • Check Web Vitals

Performance Optimization

Build Optimizations

  1. Static Export (pure HTML/CSS/JS)
  2. Code Splitting (automatic)
  3. Tree Shaking (remove unused code)
  4. Minification (compress assets)

Asset Optimization

  1. Images: Use WebP format
  2. Videos: Compress with FFmpeg
  3. Fonts: Subset and preload
  4. Icons: Use SVG or icon fonts

Monitoring & Analytics

Web Vitals

Track performance metrics:

  • LCP (Largest Contentful Paint)
  • INP (Interaction to Next Paint)
  • CLS (Cumulative Layout Shift)
  • FCP (First Contentful Paint)
  • TTFB (Time to First Byte)

Implementation: src/lib/webVitals.ts


Troubleshooting

Build Errors

Error: Image Optimization using Next.js' default loader is not compatible with export

Solution: Set images: { unoptimized: true } in next.config.mjs


Error: Module not found: Can't resolve 'fs'

Solution: Add webpack fallback in next.config.mjs


Deployment Issues

Issue: Assets not loading on GitHub Pages

Solution:

  • Check basePath and assetPrefix
  • Use getAssetPath() utility
  • Ensure trailingSlash: true

Security Considerations

Security Headers

Implemented in next.config.mjs:

  • Strict-Transport-Security (HSTS)
  • X-Frame-Options
  • X-Content-Type-Options
  • Content-Security-Policy

Best Practices

  1. Always use HTTPS in production
  2. Keep dependencies updated
  3. Never commit secrets
  4. Configure CSP properly
  5. Restrict cross-origin requests

Resources