forked from iodigital-com/SecretSanta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
50 lines (39 loc) · 1.13 KB
/
deploy.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
#!/bin/bash
set -o xtrace # print commands
set -e # exit on error
PROJECT_HOME=/var/www/secretsanta
VERSION=`date +"%Y%m%d%H%M%S"`
export SYMFONY_ENV=prod
cd $PROJECT_HOME
# Get latest version
cd git
git pull origin master
cd ..
# Deploy latest version
cp -R git releases/$VERSION
cd releases/$VERSION
cp ../../shared/parameters.yml app/config
cp ../../shared/client_secrets.json app/config
ln -s ../../export
composer.phar install --no-dev --optimize-autoloader
# Install assets
app/console assets:install web
app/console assetic:dump --env=${SYMFONY_ENV} --no-debug
cp ../../shared/yandex_* web
# Cleanup
rm -rf .git .gitignore Vagrantfile shell_provisioner
rm -rf web/app_{dev,test,test_travis}.php web/config.php
# Reset permissions
sudo chmod -R ug=rwX,o=rX ../$VERSION
sudo chmod -R a+rwX app/logs app/cache
# Activate latest
sudo service php7.1-fpm stop
app/console doctrine:schema:update --force --env=${SYMFONY_ENV}
cd ../..
ln -sfn releases/$VERSION current
sudo service php7.1-fpm start
# Cleanup old deployment, keep last 2
cd releases
ls -1 | sort -r | tail -n +3 | xargs sudo rm -rf
cd ..
echo SecretSanta version $VERSION is deployed!