No one likes to see their website broken during the static content deployment since it scares off the potential customers and causes them to bounce. Not exactly the prospective successful Magento 2 store owners look for.

Fortunately, there is the Magento 2 Zero Downtime Deployment extension that fixes this and reduces the downtime to zero. It allows you to run the deployment commands with no website breakage. Speaking of which, here is the list of the deployment commands you have to run to reduce the downtime to ZERO.

In order to redeploy Magento completely, you have to run

bin/magento magefan:zero-downtime:deploy

If you only want to deploy dependency injection (bin/magento setup:di:compile), then use

bin/magento magefan:zero-downtime:deploy -d

To run the Magento static content (bin/magento setup:static-content:deploy) use

bin/magento magefan:zero-downtime:deploy -s

In case you want to run multiple parameters script, use the following command

bin/magento magefan:zero-downtime:deploy -d -s

If you want to pull data and switch to a specific branch during deployment, use the following command

bin/magento magefan:zero-downtime:deploy -b some-new-branch

For the updating Magento 2 database data and schema (bin/magento setup:upgrade) use

bin/magento setup:upgrade --keep-generated

For switching Magento to different modes (bin/magento deploy:mode:set mode) use

bin/magento magefan:zero-downtime:deploy-mode-set --mode production
bin/magento magefan:zero-downtime:deploy-mode-set --mode developer

bin/magento magefan:zero-downtime:deploy-mode-set --mode default

To install, update, uninstall Magento 2 extensions use

bin/magento magefan:zero-downtime:composer require vendor/module-name
bin/magento magefan:zero-downtime:composer update vendor/module-name

bin/magento magefan:zero-downtime:composer remove vendor/module-name

You can also use composer options:

bin/magento magefan:zero-downtime:composer update vendor/module-name --options="--with-all-dependencies --ignore-platform-reqs"

To deploy changes without Git:

bin/magento magefan:zero-downtime:deploy -m

To deploy changes without pulling them from Git even if the Pull from Git option is enabled in the extension configuration:

bin/magento magefan:zero-downtime:deploy -g 0

To run composer commands during deployment even if the corresponding option is disabled in the extension configuration:

bin/magento magefan:zero-downtime:deploy -c 1

Note: you can use only these commands to reduce the deployment time to ZERO once you configure the Magento 2 Zero Downtime Deployment extension.