From a89befad08e84dc6d7ee7030116956c41ebec50a Mon Sep 17 00:00:00 2001 From: Romulus21 Date: Sun, 29 Mar 2020 14:17:10 +0200 Subject: [PATCH] finish deploy script --- deploy.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/deploy.sh b/deploy.sh index fff8baf..97e0917 100644 --- a/deploy.sh +++ b/deploy.sh @@ -1,9 +1,48 @@ -git pull origin production +#!/bin/bash -composer install -php artisan migrate --force -php artisan test -php artisan optimize +input=".env" +while IFS= read -r line +do + if [ "APP_ENV" == "${line%=*}" ]; + then + env="${line##*=}" + fi -npm install -npm run prod + if [ "DB_DATABASE" == "${line%=*}" ]; + then + database="${line##*=}" + fi + + if [ "DB_USERNAME" == "${line%=*}" ]; + then + user="${line##*=}" + fi + + if [ "DB_PASSWORD" == "${line%=*}" ]; + then + pass="${line##*=}" + fi + +done < "$input" + +year=$(date +"%Y") +month=$(date +"%m") +day=$(date +"%d") +hour=$(date +"%H") +minutes=$(date +"%M") + +mysqldump --user="$user" --password="$pass" -B "$database" > storage/logs/database/save_$database_$year$month$day_$hour$minutes.sql + +if [ "production" == "$env" ]; +then + echo "en production" + git pull origin production + + composer install + php artisan migrate --force + php artisan test + php artisan optimize + + npm install + npm run prod +fi