Skip to content

Instantly share code, notes, and snippets.

@MarceloHoffmeister
Last active April 3, 2020 17:52
Show Gist options
  • Save MarceloHoffmeister/4cdd3b8a8e03f327b0b1cee6091b1f47 to your computer and use it in GitHub Desktop.
Save MarceloHoffmeister/4cdd3b8a8e03f327b0b1cee6091b1f47 to your computer and use it in GitHub Desktop.
Script para deploy usando Git
#!/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