-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-web.php
More file actions
88 lines (72 loc) · 2.16 KB
/
deploy-web.php
File metadata and controls
88 lines (72 loc) · 2.16 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
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
78
79
80
81
82
83
84
85
86
87
88
<?php
require('deploy-tokens.php');
require('deploy-commands.php');
$LOG_FILE = dirname(__FILE__) . "/logs/" . date("Y_m_d-H_i_s") . ".log";
function getHeader() {
return '<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>GIT DEPLOYMENT SCRIPT</title>
</head>
<body style="background-color: #000000;
color: #FFFFFF;
font-weight: bold;
padding: 0 10px;">
<pre>
. ____ . ____________________________
|/ \| | |
[| <span style="color: #FF0000;">♥ ♥</span> |] | Git Deployment Script v0.1 |
|___==___| / © oodavid 2012 |
|____________________________|
';
}
function getFooter() {
return '
</pre>
</body>
</html>';
}
if($_GET['token'] != $deploy_web_token) {
die(getHeader() . "<h1>WRONG TOKEN</h1>" . getFooter());
}
ignore_user_abort(true);
//ini_set('output_buffering', 'off');
ini_set('zlib.output_compression', false);
//ini_set('implicit_flush', true);
//ob_implicit_flush(true);
set_time_limit(300);
ob_start();
$response = getHeader();
$response .= "<h1>Starting...</h1>";
$response .= "<p>If this is running from a Github webhook, you won't see anything more.<br/>";
$response .= "However, logs will be available in the file " . $LOG_FILE . ".</p>";
echo $response; // send the response
header('Connection: close');
header('Content-Length: '.ob_get_length());
ob_end_flush();
ob_flush();
flush();
/**
* GIT DEPLOYMENT SCRIPT
*
* Used for automatically deploying websites via github or bitbucket, more deets here:
*
* https://gist.github.com/1809044
*/
// The commands
$commands = $deploy_web_commands;
// Run the commands for output
foreach($commands AS $command){
ob_start();
$output = '';
$output .= "<span style=\"color: #6BE234;\">\$ </span><span style=\"color: #729FCF;\">{$command}\n</span>";
echo $output;
system($command);
file_put_contents($LOG_FILE, file_get_contents($LOG_FILE) . ob_get_contents());
ob_end_flush();
ob_flush();
flush();
}
echo getFooter();
?>