This repository has been archived by the owner on Sep 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
59 lines (50 loc) · 1.5 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
<?php
echo "Nature Quizzer deployment script\n";
echo "--------------------------------\n";
if (!file_exists('./.git')) {
die("Error: This deployment script should be executed only from the project root. Terminating now.\n");
}
if (file_exists('.deployment-in-progress')) {
die("Error: There was already deployment outgoing, fix issues and remove the ./.deployment-in-progress file.\n");
}
touch('.deployment-in-progress');
// Fetch and pull new sources
$state = 0;
system('git pull', $state);
if ($state !== 0) {
die("Error: Git pull failed\n");
}
// Update PHP dependencies
$state = 0;
system('php composer.phar install', $state);
if ($state !== 0) {
die("Error: Update of PHP dependencies via Composer failed.\n");
}
// Update Node.js dependencies
$state = 0;
system('npm install', $state);
if ($state !== 0) {
die("Error: Update of Node.js dependencies via node failed.\n");
}
// Remove Nette cache
$state = 0;
system('rm -rf temp/cache/*', $state);
if ($state !== 0) {
die("Error: Nette cache could not been deleted, please do it manually.\n");
}
// Regenerate files via Gulp
$state = 0;
system('./node_modules/gulp/bin/gulp.js production', $state);
if ($state !== 0) {
die("Error: Update of production files could not been finished.\n");
}
// Run database migrations
$state = 0;
system('php utils/updatedb.php', $state);
if ($state !== 0) {
die("Error: Database migrations failed.\n");
}
if (file_exists('.deployment-in-progress')) {
unlink('.deployment-in-progress');
}
echo "Info: Finished successfully\n";