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
|
<?php
$body = file_get_contents('php://input');
$request = json_decode($body, TRUE);
if(strcmp($_SERVER["HTTP_X_GITHUB_EVENT"], "release") != 0) {
die("{success:false,message:'We did not receive a release request'}");
}
$good_passwd="cd73fbf67557d29398a8fef58d367d7c92c880563c86ac9b3a74537f3207949df6024501491e19603d30957135e1562426098e47d5fbdb74620c87f6b2d396dc";
$passwd=escapeshellcmd($_GET['secret']);
echo $passwd;
$hashed_passwd=shell_exec("printf $passwd | sha512sum | cut -d ' ' -f 1");
$cmp = strcmp(trim($hashed_passwd), trim($good_passwd));
if($cmp != 0) {
die("{success:false, message:'Password incorrect', password: '$passwd', hashed_password: '$hashed_passwd'}");
}
function check($r, $m) {
if($r) {
die("{success:false, message:'$m'}");
}
}
$AUR_BUILD_DIR="/srv/http/larryshell_aur";
// Remove first v
$VERSION=substr($request["release"]["tag_name"],1);
$RELEASE="1";
/*
// --exit-code:
// 0 if no changes
// 1 if changes
system("bash $AUR_BUILD_DIR/fetch.sh");
system("git -C $AUR_BUILD_DIR/larryshell fetch");
system("git -C $AUR_BUILD_DIR/larryshell diff --exit-code HEAD FETCH_HEAD", $ret);
check(1 - $ret, 'No changes');
*/
system("bash $AUR_BUILD_DIR/build.sh $VERSION $RELEASE", $ret);
check($ret, 'Build failed');
system("git -C $AUR_BUILD_DIR add .");
$sha = system("git -C $AUR_BUILD_DIR/larryshell rev-parse --short HEAD");
system("git -C $AUR_BUILD_DIR commit -m 'Automatic version bump -- $sha'", $ret);
check($ret, 'Failed to commit');
// DAWT
system("git -C $AUR_BUILD_DIR push dawt master", $ret);
check($ret, 'Failed to push to GitHub');
// AUR
system("git -C $AUR_BUILD_DIR push origin master", $ret);
check($ret, 'Failed to push to AUR');
echo "{success:true}";
|