Last active
October 22, 2020 17:38
-
-
Save MrWeb/ed00eb8e2376f5643d3aace804ad0763 to your computer and use it in GitHub Desktop.
Autodeploy Laravel
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
Route::post('/git-auto-deploy/unique-key', function () { | |
$composer_dir = '/opt/cpanel/composer/bin'; | |
// | |
exec('printf "[Deploy Start]: $(date "+%Y-%m-%d %H:%M:%S")" >> ../deploy.log'); | |
exec("printf '\n' >> ../deploy.log"); | |
exec("git pull origin master &>>../deploy.log"); | |
exec('printf "[Deploy End]: $(date "+%Y-%m-%d %H:%M:%S")" >> ../deploy.log'); | |
exec("printf '\n' >> ../deploy.log"); | |
// | |
exec('printf "[Composer Start]: $(date "+%Y-%m-%d %H:%M:%S")" >> ../deploy.log'); | |
exec("printf '\n' >> ../deploy.log"); | |
putenv("COMPOSER_CACHE_DIR=/dev/null"); | |
putenv("COMPOSER_HOME=$composer_dir"); | |
exec("cd .. && php $composer_dir/composer install --no-interaction --prefer-dist --optimize-autoloader &>>deploy.log"); | |
exec('printf "[Composer Finish]: $(date "+%Y-%m-%d %H:%M:%S")" >> ../deploy.log'); | |
exec("printf '\n' >> ../deploy.log"); | |
// | |
exec('printf "[Migration Start]: $(date "+%Y-%m-%d %H:%M:%S")" >> ../deploy.log'); | |
exec("printf '\n' >> ../deploy.log"); | |
exec("php ../artisan migrate --force &>>../deploy.log"); | |
exec('printf "[Migration End]: $(date "+%Y-%m-%d %H:%M:%S")" >> ../deploy.log'); | |
exec("printf '\n---------------------' >> ../deploy.log"); | |
exec("printf '\n' >> ../deploy.log"); | |
// | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment