-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.php
More file actions
18 lines (15 loc) · 777 Bytes
/
Copy pathdeploy.php
File metadata and controls
18 lines (15 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
$secret = 'YOUR_WEBHOOK_SECRET_HERE';
$repo_dir = 'YOUR_SERVER_PATH_HERE';
$payload = file_get_contents('php://input');
$sig = 'sha256=' . hash_hmac('sha256', $payload, $secret);
$received_sig = $_SERVER['HTTP_X_HUB_SIGNATURE_256'] ?? '';
if (!hash_equals($sig, $received_sig)) {
http_response_code(403);
die('Forbidden: signature mismatch');
}
$output = shell_exec("cd " . escapeshellarg($repo_dir) . " && git remote set-url origin https://github.com/msenese/focus-timer.git && git fetch origin && git reset --hard origin/main 2>&1");
$log_entry = date('Y-m-d H:i:s') . "\n" . $output . "\n" . str_repeat('-', 40) . "\n";
file_put_contents(__DIR__ . '/deploy.log', $log_entry, FILE_APPEND);
http_response_code(200);
echo "Deployed at " . date('Y-m-d H:i:s');