Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 36 additions & 23 deletions docs/recipe/magento2.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ true


### artifact_file
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L378)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L385)

Artifact deployment section
The file the artifact is saved to
Expand All @@ -391,7 +391,7 @@ The file the artifact is saved to


### artifact_dir
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L381)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L388)

The directory the artifact is saved in

Expand All @@ -401,7 +401,7 @@ The directory the artifact is saved in


### artifact_excludes_file
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L385)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L392)

Points to a file with a list of files to exclude from packaging.
The format is as with the `tar --exclude-from=[file]` option
Expand All @@ -412,7 +412,7 @@ The format is as with the `tar --exclude-from=[file]` option


### build_from_repo
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L388)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L395)

If set to true, the artifact is built from a clean copy of the project repository instead of the current working directory

Expand All @@ -422,7 +422,7 @@ false


### repository
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L391)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L398)

Overrides [repository](/docs/recipe/common.md#repository) from `recipe/common.php`.

Expand All @@ -434,7 +434,7 @@ null


### artifact_path
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L394)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L401)

The relative path to the artifact file. If the directory does not exist, it will be created

Expand All @@ -447,7 +447,7 @@ return get('artifact_dir') . '/' . get('artifact_file');


### bin/tar
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L402)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L409)

The location of the tar command. On MacOS you should have installed gtar, as it supports the required settings
:::info Autogenerated
Expand All @@ -458,14 +458,14 @@ The value of this configuration is autogenerated on access.


### additional_shared_files
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L474)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L481)

Array of shared files that will be added to the default shared_files without overriding



### additional_shared_dirs
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L476)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L483)

Array of shared directories that will be added to the default shared_dirs without overriding

Expand Down Expand Up @@ -639,48 +639,61 @@ This task is group task which contains next tasks:
* [deploy:publish](/docs/recipe/common.md#deploy-publish)


### deploy\:magento\:failed {#deploy-magento-failed}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L377)

Run magento post deployment failure tasks.

Run Magento Deployment Failure Tasks


This task is group task which contains next tasks:
* [magento:config:import](/docs/recipe/magento2.md#magento-config-import)
* [magento:maintenance:disable](/docs/recipe/magento2.md#magento-maintenance-disable)


### artifact\:package {#artifact-package}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L413)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L420)

Packages all relevant files in an artifact.

tasks section


### artifact\:upload {#artifact-upload}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L423)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L430)

Uploads artifact in release folder for extraction.




### artifact\:extract {#artifact-extract}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L428)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L435)

Extracts artifact in release path.




### build\:remove-generated {#build-remove-generated}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L434)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L441)

Clears generated files prior to building.




### build\:prepare {#build-prepare}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L439)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L446)

Prepare local artifact build.




### artifact\:build {#artifact-build}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L464)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L471)

Builds an artifact.

Expand All @@ -697,15 +710,15 @@ This task is group task which contains next tasks:


### deploy\:additional-shared {#deploy-additional-shared}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L480)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L487)

Adds additional files and dirs to the list of shared files and dirs.




### magento\:set_cache_prefix {#magento-set_cache_prefix}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L495)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L502)

Update cache id_prefix.

Expand All @@ -719,15 +732,15 @@ after('deploy:magento', 'magento:cleanup_cache_prefix');


### magento\:cleanup_cache_prefix {#magento-cleanup_cache_prefix}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L535)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L542)

Cleanup cache id_prefix env files.

After successful deployment, move the tmp_env.php file to env.php ready for next deployment


### magento\:cron\:stop {#magento-cron-stop}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L551)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L558)

Remove cron from crontab and kill running cron jobs.

Expand All @@ -739,7 +752,7 @@ To use this feature, add the following to your deployer scripts:


### magento\:cron\:install {#magento-cron-install}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L567)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L574)

Install cron in crontab.

Expand All @@ -751,7 +764,7 @@ To use this feature, add the following to your deployer scripts:


### artifact\:prepare {#artifact-prepare}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L573)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L580)

Prepares an artifact on the target server.

Expand All @@ -771,7 +784,7 @@ This task is group task which contains next tasks:


### artifact\:finish {#artifact-finish}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L586)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L593)

Executes the tasks after artifact is released.

Expand All @@ -787,7 +800,7 @@ This task is group task which contains next tasks:


### artifact\:deploy {#artifact-deploy}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L595)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L602)

Actually releases the artifact deployment.

Expand Down
9 changes: 8 additions & 1 deletion recipe/magento2.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,14 @@ function magentoDeployAssetsSplit(string $area)

after('deploy:symlink', 'magento:cache:flush');

after('deploy:failed', 'magento:maintenance:disable');
after('deploy:failed', 'deploy:magento:failed');

//Run Magento Deployment Failure Tasks
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline //Run Magento Deployment Failure Tasks comment is being pulled into the autogenerated docs as a separate paragraph (see the new “Run Magento Deployment Failure Tasks” line in docs/recipe/magento2.md), which makes the docs a bit redundant/noisy. Consider either removing this comment or converting it into a clearer desc(...)/documentation text so docgen output stays clean.

Suggested change
//Run Magento Deployment Failure Tasks

Copilot uses AI. Check for mistakes.
desc('Run magento post deployment failure tasks.');
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor grammar/style: desc('Run magento post deployment failure tasks.') reads a bit awkwardly and uses inconsistent capitalization vs other Magento task descriptions in this recipe. Consider rephrasing (e.g., “Run Magento post-deployment failure tasks”) so the generated docs/help text is polished.

Suggested change
desc('Run magento post deployment failure tasks.');
desc('Run Magento post-deployment failure tasks');

Copilot uses AI. Check for mistakes.
task('deploy:magento:failed', [
'magento:config:import',
'magento:maintenance:disable',
]);

Comment on lines +377 to 381
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deploy:magento:failed runs magento:config:import, but that task resolves {{bin/magento}} via {{release_or_current_path}}. On failures that occur before deploy:symlink, the {{deploy_path}}/release symlink still exists and points to the new/failed release (see recipe/deploy/release.php + recipe/deploy/symlink.php), so the config status/import will run against the failed release instead of the still-active current release—this doesn’t restore configuration after a failed upgrade.
Consider making the failure path explicitly run config status/import against {{current_path}} (or otherwise ensure release_or_current_path resolves to current_path here) and guard it so the deploy:failed hook remains best-effort even if Magento isn’t runnable in the release directory.

Suggested change
task('deploy:magento:failed', [
'magento:config:import',
'magento:maintenance:disable',
]);
task('deploy:magento:failed', function () {
$hadReleaseOrCurrentPath = false;
$originalReleaseOrCurrentPath = null;
if (has('release_or_current_path')) {
$hadReleaseOrCurrentPath = true;
$originalReleaseOrCurrentPath = get('release_or_current_path');
}
// Ensure that config import on failure is run against the active current release,
// not the (possibly broken) new release.
set('release_or_current_path', '{{current_path}}');
try {
invoke('magento:config:import');
} catch (RunException $exception) {
// Best-effort: ignore failures during rollback config import.
} catch (GracefulShutdownException $exception) {
// Best-effort: ignore failures during rollback config import.
}
// Restore original release_or_current_path configuration if it existed before.
if ($hadReleaseOrCurrentPath) {
set('release_or_current_path', $originalReleaseOrCurrentPath);
}
try {
invoke('magento:maintenance:disable');
} catch (RunException $exception) {
// Best-effort: ignore failures when disabling maintenance mode on failure.
} catch (GracefulShutdownException $exception) {
// Best-effort: ignore failures when disabling maintenance mode on failure.
}
});

Copilot uses AI. Check for mistakes.
// Artifact deployment section

Expand Down
Loading