forked from statikbe/craft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-deploy-craft3.sh
executable file
·67 lines (60 loc) · 1.55 KB
/
post-deploy-craft3.sh
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
#!/bin/sh
#
# This script should be invoked from the root folder of your installation
#
# Usage: post-deploy.sh
# -env=<environment> define the environment you are deploying
#
# For example a post deploy for the stag environment
# ./post-deploy.sh -env=stag
#
# When exists, application/htaccess-stag will be copied to public/.htaccess
# The same for application/robots-stag which will be copied to public/robots.txt
#
# Initialize parameters
ENVIRONMENT="local"
PHP="php"
# Gather parameters from arguments
for i in "$@"
do
case $i in
--env=*|--environment=*)
ENVIRONMENT="${i#*=}"
shift
;;
*)
# unknown option
;;
esac
done
#
# Executes a command
# $1 Command to execute
# $2 Information message before the command
#
executeCommand() {
echo $2
$1
if [ $? -ne 0 ]; then
exit $?
fi
}
executeCommand "composer install --no-dev" "Installing composer requirements..."
executeCommand "chmod +x ./craft"
executeCommand "./craft migrate/all"
executeCommand "./craft project-config/apply"
FILE="config/htaccess-$ENVIRONMENT"
if [ -f $FILE ]; then
executeCommand "cp $FILE public/.htaccess" "Copying .htaccess file..."
else
echo "htaccess not found, check your environment setting"
fi
FILE="config/robots-$ENVIRONMENT"
if [ -f $FILE ]; then
executeCommand "cp $FILE public/robots.txt" "Copying robots.txt file..."
else
echo "Robots not found, check your environment setting"
fi
executeCommand "yarn install --ignore-optional"
executeCommand "yarn run prod"
echo "Done"