forked from StryKaizer/SecretSanta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
47 lines (35 loc) · 960 Bytes
/
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
#!/bin/bash
set -e # exit on error
PROJECT_HOME=/var/www/secretsanta
VERSION=`date +"%Y%m%d%H%M%S"`
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
composer.phar install
app/console doctrine:schema:update --force
# Install assets
app/console assets:install web
app/console assetic:dump -env=prod
cp ../../shared/yandex_* web
# Cleanup
rm -rf .git .gitignore Vagrantfile shell_provisioner
rm -rf web/app_dev.php web/config.php
# Reset permissions
sudo chown -R www-data:www-data ../$VERSION
sudo chmod -R ug=rwX,o= ../$VERSION
sudo chmod -R a+rwX app/logs app/cache
cd ../..
# Activate latest
ln -sfn releases/$VERSION current
sudo service apache2 restart
# 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!