Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
AFFILIATE_SOURCE=GambleCodez
DEVICE=vps
ADMIN_IDS=6668510825
BOT_TOKEN=
DISCORD_CODE_GENERATION_IMAGE_URL=https://github.com/gamblecodezcom/Runewager/blob/38c1bbab2d954238829852981514ce92c49d8b10/images/discord_code_generation.png
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,16 @@ Mode: \`${DEPLOY_MODE}\`
By: \`${{ github.actor }}\`"

# ---------------------------------------------------------------------------
# Job 2: Deploy to VPS (skipped on dry-run)
# Job 2: Deploy to VPS — DISABLED
# Deployments are performed directly on the VPS by running deploy.sh.
# GitHub Actions must NEVER launch, restart, or host the bot.
# To deploy: SSH into the VPS and run: bash /var/www/html/Runewager/deploy.sh
# ---------------------------------------------------------------------------
deploy:
name: Deploy to VPS
name: Deploy to VPS (DISABLED — run deploy.sh on VPS directly)
runs-on: ubuntu-latest
needs: quality-gates
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.dry_run != 'true' }}
if: false # GitHub must never trigger VPS restarts or bot launches
environment:
name: production

Expand Down
70 changes: 70 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
# =============================================================
# Runewager — VPS Deployment Script
#
# Run this directly on the VPS to deploy the latest code.
# GitHub Actions does NOT run this script — it is VPS-only.
#
# Usage:
# bash /var/www/html/Runewager/deploy.sh
#
# What it does:
# 1. git fetch + reset to origin/main (clean, no merge conflicts)
# 2. npm ci --omit=dev (install/update production deps)
# 3. systemctl restart runewager
# 4. Confirm service status
# =============================================================
set -euo pipefail

PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
APP_NAME="runewager"

say() { printf '[%s] %s\n' "$APP_NAME" "$*"; }
warn() { printf '[%s][warn] %s\n' "$APP_NAME" "$*" >&2; }

say "=== Runewager VPS Deployment ==="
say "Project: $PROJECT_DIR"
say "Date: $(date -u '+%Y-%m-%dT%H:%M:%SZ')"

cd "$PROJECT_DIR"

# ---------------------------------------------------------
# 1) Pull latest code from origin/main
# ---------------------------------------------------------
say "Step 1/4 — Fetching latest code from origin/main…"
git fetch --all
git reset --hard origin/main
say "Now at: $(git rev-parse --short HEAD)"

# ---------------------------------------------------------
# 2) Install / update production dependencies
# ---------------------------------------------------------
say "Step 2/4 — Installing production dependencies…"
if [[ -f package-lock.json ]]; then
npm ci --omit=dev
else
npm install --omit=dev
fi
say "Dependencies installed."

# ---------------------------------------------------------
# 3) Restart via systemctl
# ---------------------------------------------------------
say "Step 3/4 — Restarting bot via systemctl…"
if command -v systemctl >/dev/null 2>&1; then
systemctl restart "${APP_NAME}.service"
say "Bot restarted."
else
warn "systemctl not found. Restart manually: node $PROJECT_DIR/index.js"
fi

# ---------------------------------------------------------
# 4) Confirm service status
# ---------------------------------------------------------
say "Step 4/4 — Confirming bot status…"
sleep 3
ACTIVE="$(systemctl is-active "${APP_NAME}.service" 2>/dev/null || echo unknown)"
say "Service status: $ACTIVE"

say ""
say "=== Deployment complete. ==="
Loading
Loading