# GitHub Actions Production Deployment Setup

This document explains how to configure GitHub Actions secrets for automatic and manual deployments of `shinecode-frontend` (`Predarox/SC-FR`) to your production VPS.

---

## 1. Required GitHub Repository Secrets

In your GitHub repository:
1. Navigate to: **Settings** > **Secrets and variables** > **Actions**.
2. Click **New repository secret** for each of the following variables:

| Secret Name | Description | Example Value |
| :--- | :--- | :--- |
| `VPS_HOST` | Production VPS IP address or hostname | `shinecode.ae` or VPS IP |
| `VPS_USERNAME` | Deploy user or root on the VPS | `root` or `sc` or `deploy` |
| `VPS_SSH_KEY` | Private SSH Key for authenticating to VPS | `-----BEGIN OPENSSH PRIVATE KEY...` |
| `DEPLOY_PATH`| Root directory on VPS where app resides (optional, defaults to `$HOME/shinecode_frontend`) | `/home/sc/shinecode_frontend` |
| `PM2_APP_NAME`| PM2 process name (optional, auto-detects `shinecode-frontend` or `shinecode-web`) | `shinecode-frontend` |

> [!IMPORTANT]
> **Zero Secrets in Code**: Never commit SSH keys, passwords, or server credentials into git. All communication is authenticated using encrypted GitHub Secrets.

---

## 2. Server Prerequisites

On your production VPS, ensure the following are installed:
1. **Node.js**: >= 22.0.0 (Node 22 LTS required for Next.js 16)
2. **npm**: >= 9.0.0
3. **PM2**: `npm install -g pm2`
4. **Git**: Configured to access `git@github-frontend:Predarox/SC-FR.git` or `git@github.com:Predarox/SC-FR.git`

### Environment Configuration on VPS
Create `/home/sc/shinecode_frontend/apps/web/.env.production` (or `.env.local`) on the VPS:
```env
NEXT_PUBLIC_API_URL=https://shinecode.ae/api
INTERNAL_API_URL=http://127.0.0.1
INTERNAL_HOST_HEADER=shinecode.ae
NEXT_PUBLIC_BOOKING_URL=https://shinecode.ae
NEXT_PUBLIC_ENV=production
NEXT_PUBLIC_TURNSTILE_SITE_KEY=your_turnstile_site_key
REVALIDATION_SECRET=your_revalidation_secret
PORT=3000
```

---

## 3. How Deployments Run 

- **Automatic Deploy**: Every push to the `main` branch automatically triggers CI validation (type-check, lint, build test), followed by zero-downtime PM2 reload on the VPS.
- **Manual Trigger**: You can manually deploy at any time by going to **Actions** > **Production Deployment (VPS PM2)** > **Run workflow**.
