-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.php
34 lines (29 loc) · 980 Bytes
/
deploy.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
<?php
include('config.php');
$payload = file_get_contents('php://input');
if (empty($payload)) {
die('No payload present');
} else {
$useablepayload = json_decode($payload);
$payloadbranch = $useablepayload->{'ref'};
foreach ($repos as $repo) {
if (strpos($payloadbranch, $repo['branchname']) !== false) {
$cdcommand = 'cd '.$repo['path'].' && ';
}
}
$pwd = shell_exec('pwd');
$commands = array(
$cdcommand.'pwd',
$cdcommand.GITPATH.' reset --hard HEAD 2>&1',
$cdcommand.GITPATH.' pull 2>&1',
$cdcommand.GITPATH.' status 2>&1',
$cdcommand.GITPATH.' submodule sync 2>&1',
$cdcommand.GITPATH.' submodule update 2>&1',
$cdcommand.GITPATH.' submodule status 2>&1',
'find '.$pwd.' -type d -exec chmod 755 {} \;',
'find '.$pwd.' -type f -exec chmod 644 {} \;',
);
foreach ($commands as $command) {
echo shell_exec($command);
}
}