This repository was archived by the owner on Apr 12, 2019. It is now read-only.
forked from vicenteguerra/git-deploy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.php
More file actions
46 lines (39 loc) · 1.22 KB
/
deploy.php
File metadata and controls
46 lines (39 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
require_once("config.php");
$content = file_get_contents("php://input");
$json = json_decode($content, true);
$file = fopen(LOGFILE, "a");
$time = time();
date_default_timezone_set("UTC");
fputs($file, date("d-m-Y (H:i:s)", $time) . "\n");
if (!isset($_GET["token"]) || $_GET["token"] !== TOKEN) {
header("HTTP/1.0 403 Forbidden");
fputs($file, "Access Denied" . "\n");
exit;
} else {
if ($json["ref"] == BRANCH) {
fputs($file, $content . PHP_EOL);
if (file_exists(DIR . ".git") && is_dir(DIR)) {
try {
chdir(DIR);
shell_exec(GIT . " pull");
if (!empty(AFTER_PULL)) {
try {
shell_exec(AFTER_PULL);
} catch (Exception $e) {
fputs($file, $e . "\n");
}
}
fputs($file, "*** AUTO PULL SUCCESFUL ***" . "\n");
} catch (Exception $e) {
fputs($file, $e . "\n");
}
} else {
fputs($file, "DIR Not Found" . "\n");
}
} else{
fputs($file, "Push in: " . $json["ref"] . "\n");
}
}
fputs($file, "\n\n" . PHP_EOL);
fclose($file);