-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·41 lines (29 loc) · 1.06 KB
/
deploy.sh
File metadata and controls
executable file
·41 lines (29 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
#!/bin/bash
set -e
MYSQL_PASSWORD=$1
PROJECT_DIR="/var/www/tg.lnk-dev.ru"
REPOSITORY="git@github.com:dev-lnk/telegram-admin.git"
USER="develop"
# make dir if not exists (first deploy)
mkdir -p $PROJECT_DIR
cd $PROJECT_DIR
git config --global --add safe.directory $PROJECT_DIR
# the project has not been cloned yet (first deploy)
if [ ! -d $PROJECT_DIR"/.git" ]; then
GIT_SSH_COMMAND="ssh -i /home/$USER/.ssh/id_ed25519 -o IdentitiesOnly=yes" git clone $REPOSITORY .
else
GIT_SSH_COMMAND="ssh -i /home/$USER/.ssh/id_ed25519 -o IdentitiesOnly=yes" git pull
fi
composer install --no-interaction --optimize-autoloader --no-dev
# initialize .env if does not exist (first deploy)
if [ ! -f $PROJECT_DIR"/.env" ]; then
cp .env.example .env
sed -i "/DB_PASSWORD/c\DB_PASSWORD=$MYSQL_PASSWORD" $PROJECT_DIR"/.env"
sed -i '/QUEUE_CONNECTION/c\QUEUE_CONNECTION=database' $PROJECT_DIR"/.env"
php artisan key:generate
fi
sudo chown -R www-data:www-data $PROJECT_DIR
php artisan storage:link
php artisan optimize:clear
php artisan migrate --force
php artisan optimize