chore: add deploy script and inv cols check script

This commit is contained in:
DevSoftTech Server 2026-05-19 20:50:19 +05:30
parent a56e8a5776
commit 83685d98be
2 changed files with 46 additions and 0 deletions

33
deploy.sh Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
# deploy.sh — Push local changes and deploy to production server
# Usage: bash deploy.sh "commit message"
# Requires: PuTTY plink at default location (Windows) or ssh (Linux/Mac)
#
# Server: 159.89.175.190 Project: /var/www/html/hms_etria
set -e
MSG="${1:-Auto-deploy $(date '+%Y-%m-%d %H:%M')}"
SERVER="root@159.89.175.190"
PROJECT="/var/www/html/hms_etria"
echo "=== Staging and committing ==="
git add -A
# Don't commit env (server has its own)
git reset HEAD env 2>/dev/null || true
git diff --cached --stat
git commit -m "$MSG" 2>/dev/null || echo "(nothing to commit)"
echo "=== Pushing to GitHub ==="
git push origin main
echo "=== Deploying to server ==="
REMOTE_CMDS="cd $PROJECT && git config core.fileMode false && git pull origin main && php spark migrate --namespace App && echo DEPLOY_OK"
if command -v plink &>/dev/null; then
plink -ssh -batch -pw "$HMS_SSH_PASS" $SERVER "$REMOTE_CMDS"
else
ssh -o StrictHostKeyChecking=no $SERVER "$REMOTE_CMDS"
fi
echo "=== Done ==="

View File

@ -0,0 +1,13 @@
<?php
$dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__), 'env');
$dotenv->safeLoad();
$db = mysqli_connect(
getenv('database.default.hostname') ?: 'localhost',
getenv('database.default.username') ?: 'root',
getenv('database.default.password') ?: '',
getenv('database.default.database') ?: 'hms_data_ci4'
);
$r = mysqli_query($db, 'SHOW COLUMNS FROM investigation');
while ($row = mysqli_fetch_assoc($r)) {
echo $row['Field'] . ' (' . $row['Type'] . ')' . PHP_EOL;
}