Skip to content

Instantly share code, notes, and snippets.

@acbilimoria
Created May 5, 2017 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acbilimoria/52d857f7a13c7e40d00304d6b4ab1083 to your computer and use it in GitHub Desktop.
Save acbilimoria/52d857f7a13c7e40d00304d6b4ab1083 to your computer and use it in GitHub Desktop.
One Touch Build & Deploy - Laravel 5.4 on LEMP Stack Ubuntu 16.04
#!/usr/bin/env ruby
# 1. Read STDIN (Format: "from_commit to_commit branch_name")
from, to, branch = ARGF.read.split " "
# 2. Only deploy if master branch was pushed
if (branch =~ /master$/) == nil
puts "Received branch #{branch}, not deploying."
exit
end
# 3. Copy files to deploy directory
deploy_to_dir = File.expand_path('/var/www/SITE-DIRECTORY')
`GIT_WORK_TREE="#{deploy_to_dir}" git checkout -f master`
puts "DEPLOY: master(#{to}) copied to '#{deploy_to_dir}'"
# 4. Deployment Tasks
exec("cd /var/www/SITE-DIRECTORY/ ; ./production-build.sh")
# disable debugging
sed -i "s/'debug' => env('APP_DEBUG', true),/'debug' => env('APP_DEBUG', false),/g" config/app.php
composer install --no-dev --optimize-autoloader
npm run production
php artisan optimize
php artisan route:cache
php artisan cache:clear
php artisan migrate
phpunit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment