forked from nllarson/github-deploy-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub.php
77 lines (66 loc) · 1.73 KB
/
github.php
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
include('github.config.php');
function myException($exception)
{
$body=$exception->getMessage();
$subject="Deployment ERROR";
$headers = "From: ".$from_email."\n";
mail($to_email,$subject,$body,$headers);
}
set_exception_handler('myException');
//$reason = "START";
if ($enabled)
{
$data = json_decode($_POST[payload], true);
$pusher = $data[pusher][name];
$pusher_email = $data[pusher][email];
//$reason = " -- ENABLED";
$safe_to_deploy = true;
if ($limit_users)
{
$safe_to_deploy = false;
//$reason .= " -- Limit Users";
if(in_array($pusher, $valid_users))
{
$safe_to_deploy = true;
//$reason .= " -- VALID";
}
}
else
{
$safe_to_deploy = false;
//$reason .= " -- No Limit Users";
if (isset($pusher) && isset($pusher_email))
{
//$reason .= " -- PUSHER OK";
$safe_to_deploy = true;
}
}
if ($safe_to_deploy)
{
//$reason .= " -- SAFE TO DEPLOY";
$repo = $data[repository][name];
$repo_url = $data[repository][url];
//`git pull`;
$body="Site: ".$site_name."\n Pusher: ".$pusher."\n Pusher Email: ".$pusher_email."\n Repo: ".$repo."\n Repo URL: ".$repo_url."\n";
$subject="Deployment - ".$site_name;
$headers = "From: ".$from_email."\n";
}
else
{
//$reason .= " -- FAIL TO DEPLOY";
$body="Site: ".$site_name."\n IP: ".$_SERVER['REMOTE_ADDR']."\n\n\n".serialize($_REQUEST);
$subject="Deployment Failure - ".$site_name;
$headers = "From: ".$from_email."\n";
}
}
else
{
//$reason = " -- DISABLED";
$body="Site: ".$site_name."\n IP: ".$_SERVER['REMOTE_ADDR']."\n\n\n".serialize($_REQUEST);
$subject="Deployment Disabled - ".$site_name;
$headers = "From: ".$from_email."\n";
}
//mail($to_email,$subject,$body."\n --- \n".$reason,$headers);
mail($to_email,$subject,$body,$headers);
?>