getExitCode() == CONFIG_IMPORT_NEEDED_EXIT_CODE) { $configImportNeeded = true; } else { throw $e; } } } if ($configImportNeeded) { if (!get('maintenance_mode_status_active')) { invoke('magento:maintenance:enable'); } run('{{bin/php}} {{release_path}}/bin/magento app:config:import --no-interaction'); if (!get('maintenance_mode_status_active')) { invoke('magento:maintenance:disable'); } } }); desc('Upgrade magento database'); task('magento:upgrade:db', function () { $databaseUpgradeNeeded = false; try { run('{{bin/php}} {{release_path}}/bin/magento setup:db:status'); } catch (RunException $e) { if ($e->getExitCode() == DB_UPDATE_NEEDED_EXIT_CODE) { $databaseUpgradeNeeded = true; } else { throw $e; } } if ($databaseUpgradeNeeded) { if (!get('maintenance_mode_status_active')) { invoke('magento:maintenance:enable'); } run("{{bin/php}} {{release_path}}/bin/magento setup:upgrade --keep-generated"); if (!get('maintenance_mode_status_active')) { invoke('magento:maintenance:disable'); } } }); desc('Flush Magento Cache'); task('magento:cache:flush', function () { run("{{bin/php}} {{release_path}}/bin/magento cache:flush"); }); desc('Magento2 deployment operations'); task('deploy:magento', [ 'magento:compile', 'magento:deploy:assets', 'magento:config:import', 'magento:upgrade:db', 'magento:cache:flush' ]); desc('Deploy your project'); task('deploy', [ 'deploy:prepare', 'deploy:vendors', 'deploy:clear_paths', 'deploy:magento', 'deploy:publish', ]); after('deploy:failed', 'magento:maintenance:disable');