Skip to content

Instantly share code, notes, and snippets.

@shebin512
Forked from rafaelstz/magedeploy.sh
Created August 8, 2021 18:44
Show Gist options
  • Save shebin512/73a13e483345c25ca929942138e05ac8 to your computer and use it in GitHub Desktop.
Save shebin512/73a13e483345c25ca929942138e05ac8 to your computer and use it in GitHub Desktop.
Magento 2 Deploy script
#!/usr/bin/env bash
LANGUAGES="en_US pt_BR"
# production or developer
ENVIRONMENT="production"
COMPOSER=$(which composer)
PHP=$(which php)
ROOT=$(pwd)
MAGENTO=$(pwd)'/bin/magento'
echo "Magento maintenance mode enable"
$PHP $MAGENTO maintenance:enable &&
echo "Git reset"
git fetch origin &&
git reset --hard origin &&
git pull origin &&
echo "Composer"
if [ "$ENVIRONMENT" == "production" ]; then
$COMPOSER install --no-dev
else
$COMPOSER install
fi
echo "Magento deploy"
$PHP $MAGENTO setup:upgrade &&
$PHP $MAGENTO cache:enable &&
if [ "$ENVIRONMENT" == "production" ]; then
echo "Production deploy"
$PHP $MAGENTO deploy:mode:set production --skip-compilation &&
$PHP $MAGENTO config:set dev/js/move_script_to_bottom 1 &&
$PHP $MAGENTO config:set dev/js/enable_js_bundling 0 &&
$PHP $MAGENTO config:set dev/js/merge_files 1 &&
$PHP $MAGENTO config:set dev/js/minify_files 1 &&
$PHP $MAGENTO config:set design/head/default_robots 'INDEX,FOLLOW' &&
$PHP $MAGENTO config:set google/analytics/active 1
else
echo "Development deploy"
$PHP $MAGENTO deploy:mode:set developer &&
$PHP $MAGENTO config:set dev/js/move_script_to_bottom 0 &&
$PHP $MAGENTO config:set dev/js/enable_js_bundling 0 &&
$PHP $MAGENTO config:set dev/js/merge_files 0 &&
$PHP $MAGENTO config:set dev/js/minify_files 0 &&
$PHP $MAGENTO config:set google/analytics/active 0 &&
$PHP $MAGENTO config:set design/head/default_robots 'NOINDEX,NOFOLLOW'
fi
$PHP $MAGENTO setup:di:compile &&
$PHP $MAGENTO setup:static-content:deploy $LANGUAGES -f &&
$PHP $MAGENTO indexer:reindex &&
$PHP $MAGENTO cache:clean &&
$PHP $MAGENTO maintenance:disable &&
echo "Deploy completed 🎉"
# Created by Rafael Corrêa Gomes (https://github.com/rafaelstz)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment