Last active
April 3, 2020 17:52
-
-
Save MarceloHoffmeister/4cdd3b8a8e03f327b0b1cee6091b1f47 to your computer and use it in GitHub Desktop.
Script para deploy usando Git
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/bash | |
# script baseado no Codecasts para deploy pelo Git | |
# https://github.com/codecasts/server-templates/blob/master/post-receive | |
while read oldrev newrev ref | |
# Variables | |
USER_PATH='/home/user' | |
REPO_PATH=$USER_PATH"/repo" | |
STAGING_PATH=$USER_PATH"/staging" | |
PRODUCTION_PATH=$USER_PATH"/production" | |
do | |
branch=`echo $ref | cut -d/ -f3` | |
export GIT_DIR=$REPO_PATH | |
if [ "develop" == "$branch" ]; then | |
echo "Deploying STAGING" | |
export GIT_WORK_TREE=$STAGING_PATH | |
git checkout -f $branch | |
cd $STAGING_PATH | |
composer install | |
php artisan migrate --force | |
gulp | |
php artisan cache:clear | |
elif [ "master" == "$branch" ]; then | |
echo "Deploying PRODUCTION" | |
export GIT_WORK_TREE=$PRODUCTION_PATH | |
git checkout -f $branch | |
cd $PRODUCTION_PATH | |
composer install | |
php artisan migrate --force | |
gulp | |
php artisan cache:clear | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment