Last active
February 24, 2021 11:40
-
-
Save zetrider/3ad356bf2c9b92be5931c5687204227b to your computer and use it in GitHub Desktop.
Laravel: Bash deploy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Grant privileges | |
# echo "YOUR_USER ALL=NOPASSWD: /usr/sbin/service php7.4-fpm reload" | sudo tee -a /etc/sudoers.d/php-fpm > /dev/null | |
# echo "YOUR_USER ALL=NOPASSWD: /usr/sbin/service nginx restart" | sudo tee -a /etc/sudoers.d/php-fpm > /dev/null | |
# echo "YOUR_USER ALL=NOPASSWD: /usr/sbin/service supervisor restart" | sudo tee -a /etc/sudoers.d/php-fpm > /dev/null | |
NAME=$(date +"%m-%d-%Y-%H-%M-%S") | |
FOLDER=releases/$NAME | |
BACKUP=backup/before_$NAME.sql | |
echo "Backup..." | |
mysqldump -u USER -pPASSWORD DATABASE > $BACKUP | |
mkdir ${FOLDER} | |
cd ${FOLDER} | |
echo "Git clone..." | |
git clone [email protected]:USER/PROJECT.git . | |
rm -rf storage | |
ln -s ../../storage storage | |
ln -s ../../.env .env | |
echo "Composer install..." | |
composer install | |
echo "Npm install..." | |
npm install | |
npm run production | |
echo "Artisan..." | |
php artisan storage:link | |
php artisan route:clear | |
php artisan cache:clear | |
php artisan migrate --force | |
php artisan queue:restart | |
read -p "Restart and deploy? y/n:" answer | |
if [ $answer = "y" ]; then | |
cd ../../ | |
if [ -f current ]; then | |
rm current; | |
fi | |
ln -s ${FOLDER} current | |
sudo service php7.4-fpm reload | |
sudo service nginx restart | |
sudo service supervisor restart | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment