A bunch of tasks for Magento 2 to play with Magallanes v4.
- magento/apply-patches
- magento/cache-clean
- magento/cache-flush
- magento/cache-disable
- magento/cache-enable
- magento/cache-status
- magento/compile-code
- magento/compile-themes
- magento/config-dump
- magento/config-import
- magento/config-verify
- magento/data-upgrade
- magento/schema-upgrade
- magento/db-status
- magento/deploy-mode-production
- magento/show-app-mode
- magento/maintenance-on
- magento/maintenance-off
- magento/maintenance-status
- magento/setup-permissions
- magento/setup-upgrade
- magento/custom
- frontools/setup
- frontools/compile-themes
- sass/setup
- sass-migrator/setup
- sass-migrator/execute
- magepack/setup
- magepack/bundle
Install via composer:
composer require nntoan/magallanes-magento2
Then add the provided tasks as custom tasks in .mage.yml to use them:
magephp:
...
custom_tasks:
- 'Mage\Magento\Task\MagentoCacheFlushTask'
- 'Mage\Magento\Tasks\MagentoSetupUpgradeTask'
...
Notes:
- List of available classes is available in vendor/nntoan/magallanes-magento2/src/Task
- You can add only the tasks you require in your deployment script
After adding the tasks you want to use to the list of custom classes, you can use them in any deployment step, like so:
magephp:
environments:
prod:
magento: { use_docker: true }
pre-deploy:
on-deploy:
- magento/maintenance-on
- magento/deploy-mode-production
- magento/setup-upgrade
- magento/compile-code
- magento/compile-themes: { flags: 'en_US en_VN -t Magento/luma' }
on-release:
post-release:
- magento/cache-flush
- magento/maintenance-off
post-deploy:
All the Magento tasks have the following common parameters:
- use_docker: Required if you are using docker on your environments (optional)
- magento_dir: The path to cd into before running the command (optional)
To avoid repetition, you can specify these parameters with the global configuration item "magento". This item can be set in the global level or for each environment.
Global level:
magephp:
...
magento: { use_docker: true }
...
Per environment:
magephp:
environments:
uat:
...
magento: { use_docker: false, magento_dir: './src' }
...
prod:
...
magento: { use_docker: true }
...
Moreover, each configuration item overrides the parent one, so a global magento configuration can be set and them overridden on a specific environment or even on a per-command basis.
Examples:
magephp:
magento: { use_docker: true }
environments:
uat:
...
# Only UAT env has a different value for whatever reason.
magento: { use_docker: false }
...
prod:
...
# Will use the global "use_docker" value.
...
magephp:
magento: { alias: mywebsite }
environments:
prod:
pre-deploy:
- magento/config-dump { use_docker: false, magento_dir: './src' }
on-deploy:
on-release:
post-release:
- magento/setup-upgrade: { zero_downtime: true }
- magento/config-import
- magento/cache-flush
post-deploy:
Description: Clean Magento cache by types
Magento command: bin/magento cache:clean
Description: Flush Magento cache storage
Magento command: bin/magento cache:flush
Description: Enable Magento cache
Magento command: bin/magento cache:enable
Description: Disable Magento cache
Magento command: bin/magento cache:disable
Description: Check Magento cache enabled status
Magento command: bin/magento cache:status
Description: Runs dependency injection compilation routine
Magento command: bin/magento setup:di:compile
Options:
- timeout (optional): Use to set timeout for the command can be on the server (default is 120).
Description: Deploys static view files
Magento command: bin/magento setup:static-content:deploy
Options:
- flags (optional): all options and agruments you would like to pass to this command. Eg: "en_AU en_US --exclude-theme=Magento/luma"
- timeout (optional): Use to set timeout for the command can be on the server (default is 120).
Description: Create dump of application config
Magento command: bin/magento app:config:dump
Options:
- params (optional): Config scopes you would like to dump. Eg: "scopes themes i18n"
Description: Import data from shared config files
Magento command: bin/magento app:config:import
Description: Checks if config propagation requires update
Magento command: bin/magento app:config:status
Description: Upgrades data fixtures
Magento command: bin/magento setup:db-data:upgrade
Description: Upgrades database schema
Magento command: bin/magento setup:db-schema:upgrade
Description: Checks if DB schema or data requires upgrade
Magento command: bin/magento setup:db:status
Description: Enables production mode
Magento command: bin/magento deploy:mode:set production --skip-compilation
Description: Displays current application mode
Magento command: bin/magento deploy:mode:show
Description: Enable maintenance mode
Magento command: bin/magento maintenance:enable
Description: Disable maintenance mode
Magento command: bin/magento maintenance:disable
Description: Displays maintenance mode status
Magento command: bin/magento maintenance:status
Description: Updates the module load sequence and upgrades database schemas and data fixtures
Magento command: bin/magento setup:upgrade
Options:
- zero_downtime (optional): Force keep generated files. Eg: "true/false"
- timeout (optional): Use to set timeout for the command can be on the server (default is 120).
Description: Updates the module load sequence and upgrades database schemas and data fixtures
File command: find . -type f ! -perm %s -exec chmod %s {}
Directory command: find . -type d ! -perm %s -exec chmod %s {}
Options:
- file (mandatory): Permission you would like to set for all files. Eg: "0644"
- directory (mandatory): Permission you would like to set for all directories. Eg: "0755"
Description: Run a specified magento
command. Use only if you can't create a proper custom Magallanes task.
Magento command: bin/magento <your command>
Options:
- command (mandatory): the magento command to run, without the "magento" part. Eg: "indexer:reindex"
Feel free to submit your pull requests to add new Magento commands. Your requests must be done on branch master. Rules :
- Magento command must be a command that is helping during multiple deployment process
- Your command class must inherit from Mage\Magento\Task\AbstractTask