-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathdeploy.sh
More file actions
49 lines (37 loc) · 1.06 KB
/
deploy.sh
File metadata and controls
49 lines (37 loc) · 1.06 KB
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
#!/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
composer.phar install --no-dev --optimize-autoloader
app/console doctrine:schema:update --force --env=${SYMFONY_ENV}
# 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.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!