Skip to content

Instantly share code, notes, and snippets.

@acacha
Forked from BenSampo/deploy.sh
Last active March 3, 2022 17:44
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 acacha/9bd560e39de2fcb6f3f9d9592f1fd58d to your computer and use it in GitHub Desktop.
Save acacha/9bd560e39de2fcb6f3f9d9592f1fd58d to your computer and use it in GitHub Desktop.
Laravel deploy script
# Change to the project directory
cd $FORGE_SITE_PATH
# Turn on maintenance mode
if [ -f artisan ]; then
$FORGE_PHP artisan down || true
fi
# Pull the latest changes from the git repository
git reset --hard origin/production
git clean -df
git pull origin $FORGE_SITE_BRANCH
# Install/update composer dependecies
$FORGE_COMPOSER install --no-interaction --prefer-dist --optimize-autoloader --no-dev
# Restart FPM
( flock -w 10 9 || exit 1
echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock
# Run database migrations
if [ -f artisan ]; then
$FORGE_PHP artisan migrate --force
# Clear caches
$FORGE_PHP artisan cache:clear
# Clear expired password reset tokens
$FORGE_PHP artisan auth:clear-resets
# Clear and cache routes
$FORGE_PHP artisan route:cache
# Clear and cache config
$FORGE_PHP artisan config:cache
# Clear and cache views
$FORGE_PHP artisan view:cache
# Restart queues: https://medium.com/@taylorotwell/properly-deploying-queues-on-forge-5abe1eac6d1c
$FORGE_PHP artisan queue:restart
# Crear link public storage
$FORGE_PHP artisan storage:link
fi
# Install node modules
npm ci
# Build assets using Laravel Mix
npm run production
if [ -f artisan ]; then
# Turn off maintenance mode
$FORGE_PHP artisan up
fi
@acacha
Copy link
Author

acacha commented Feb 3, 2022

hey afegit origin production al reset hard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment