Files
HRM-System/public/git-pull.php

48 lines
1.3 KiB
PHP

<?php
/**
* Standalone Git Pull Deployment Script for Shared Hosting
* Location: public/git-pull.php
*/
define('SECURE_TOKEN', '7f3b89e902a2cdb8b5de9f2e30f14d8a245fca9b');
// Verify token
if (!isset($_GET['token']) || $_GET['token'] !== SECURE_TOKEN) {
header('HTTP/1.0 403 Forbidden');
echo "Access Denied: Invalid or missing security token.";
exit;
}
header('Content-Type: text/plain; charset=utf-8');
echo "=========================================\n";
echo "Starting Git Pull Deployment Workflow\n";
echo "Current Time: " . date('Y-m-d H:i:s') . "\n";
echo "=========================================\n\n";
// Move to the root directory (one level up from public)
$rootPath = realpath(__DIR__ . '/../');
chdir($rootPath);
echo "Working Directory: " . getcwd() . "\n\n";
// Helper function to execute and print command output
function execute($cmd) {
echo "$ {$cmd}\n";
$output = shell_exec($cmd);
echo $output ? trim($output) : "(no output)";
echo "\n-----------------------------------------\n";
}
// 1. Check current status
execute("git status");
// 2. Pull latest changes
execute("git pull origin main 2>&1");
// 3. Re-optimize Laravel cache and run migrations
execute("php artisan optimize:clear 2>&1");
execute("php artisan migrate --force 2>&1");
echo "Deployment workflow finished.\n";