-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
95 lines (80 loc) · 2.63 KB
/
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
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
89
90
91
92
93
94
95
<?php
require_once ("config.inc.php");
$ignorelist = array(
"Fetching origin",
"Fetching RileyHuntley",
"Fetching stwalkerster",
"Fetching stw",
"Fetching FunPika",
"Fetching JohnFLewis",
"Fetching cyberpower678",
"Fetching t13",
"Fetching manishearth",
"Fetching mrb",
"Fetching mdaniels5757",
"Fetching theo",
"Fetching fastlizard4",
"Fetching methecooldude",
"You are not currently on a branch, so I cannot use any",
"'branch.<branchname>.merge' in your configuration file.",
"Please specify which remote branch you want to use on the command",
"line and try again (e.g. 'git pull <repository> <refspec>').",
"See git-pull(1) for details.",
"You are in 'detached HEAD' state. You can look around, make experimental",
"changes and commit them, and you can discard any commits you make in this",
"state without impacting any branches by performing another checkout.",
"If you want to create a new branch to retain commits you create, you may",
"do so (now or later) by using -b with the checkout command again. Example:",
" git checkout -b new_branch_name",
"Please specify which branch you want to merge with on the command",
"Submodule 'lib/bootstrap-sortable' () registered for path 'lib/bootstrap-sortable'",
"Submodule 'lib/password_compat' () registered for path 'lib/password_compat'",
"Submodule 'lib/mediawiki-extensions-OAuth' () registered for path 'lib/mediawiki-extensions-OAuth'",
);
$revision = isset( $_GET['r'] ) ? $_GET['r'] : '';
if( $revision == '' ) {
echo("Please specify a revision");
die;
}
$key = isset( $_GET['k'] ) ? $_GET['k'] : '';
if( $key == '' ) {
echo("Please specify a key");
die;
}
if( md5( md5($revision) . $apiDeployPassword ) != $key ) {
echo("Invalid key.");
die;
}
// get the latest stuff from the remotes.
$fetchOutput = array();
exec( './fetch.sh', $fetchOutput );
foreach( $fetchOutput as $line )
{
if(! in_array( $line, $ignorelist ) )
{
echo $line . "\n";
}
}
$found = false;
$revlist = array();
exec( './revlist.sh 2>&1', $revlist );
foreach( $revlist as $rev )
{
if(trim($rev) == $revision)
{
$found = true;
break;
}
}
if(!$found)
{
echo("Revision not found. Please use entire SHA1 or remote branch format (eg. origin/master)");
die;
}
echo "Running deployment...\n";
$output = array();
exec( './deploy.sh ' . escapeshellarg($revision) . ' 2>&1', $output );
$fileName = uniqid('logs/') . '.log';
file_put_contents($fileName, implode("\n", $output));
echo "Deployment complete. Please review the deployment log at https://accounts-dev.wmflabs.org/deploy/${fileName}\n";
die;