Skip to content

Instantly share code, notes, and snippets.

@gravitano
Last active December 14, 2021 12:19
Show Gist options
  • Save gravitano/4a86e2de978c45aa2264 to your computer and use it in GitHub Desktop.
Save gravitano/4a86e2de978c45aa2264 to your computer and use it in GitHub Desktop.
Simple laravel envoy deploy script :)
@servers(['web' => '[email protected]'])
@setup
$root = '~/public_html';
$dir = $root . '/laravel';
$branch = 'master';
$artisan = $dir . '/artisan';
$composer = '~/composer.phar';
$repo = '[email protected]:username/repository.git';
@endsetup
@macro('deploy')
down
pull
env
update
migrate
up
@endmacro
@task('fetch')
cd {{ $root }};
if [ -d {{ $dir }} ]; then
rm -rf {{ $dir }};
fi;
git clone -b {{ $branch }} {{ $repo }} {{ $dir }};
@endtask
@task('pull')
cd {{ $dir }} && git pull origin {{ $branch }}
@endtask
@task('update')
cd {{ $dir }} && {{ $composer }} update -v
@endtask
@task('install')
cd {{ $dir }} && {{ $composer }} install -v
@endtask
@task('env')
cp {{ $dir }}/.env.production {{ $dir }}/.env
@endtask
@task('down')
if [ -f {{ $artisan }} ]; then
php {{ $artisan }} down
else
echo "Artisan file not found!"
fi
@endtask
@task('up')
if [ -f {{ $artisan }} ]; then
php {{ $artisan }} up
else
echo "Artisan file not found!"
fi
@endtask
@task('migrate')
if [ -f {{ $artisan }} ]; then
php {{ $artisan }} migrate --force
else
echo "Artisan file not found!"
fi
@endtask
@task('migrate:refresh')
if [ -f {{ $artisan }} ]; then
php {{ $artisan }} migrate:refresh --force
else
echo "Artisan file not found!"
fi
@endtask
@task('seed')
if [ -f {{ $artisan }} ]; then
php {{ $artisan }} db:seed --force
else
echo "Artisan file not found!"
fi
@endtask
@task('migrate:reset')
if [ -f {{ $artisan }} ]; then
php {{ $artisan }} migrate:reset --force
else
echo "Artisan file not found!"
fi
@endtask
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment