turbine-kreuzberg/spryker-deploy-tasks

为Spryker执行部署任务,基于环境和存储

1.0.1 2024-08-23 13:45 UTC

This package is auto-updated.

Last update: 2024-09-26 15:46:56 UTC


README

此包为Spryker提供在部署后根据环境和存储执行一次任务的功能。

安装

composer require [--dev] turbine-kreuzberg/spryker-deploy-tasks

设置

要使用提供的控制台命令,您需要在 config/Shared/config_default.php 中注册命名空间 TurbineKreuzberg

$config[KernelConstants::CORE_NAMESPACES] = [
    // add 'TurbineKreuzberg' as a core namespace
    'TurbineKreuzberg',
];

src/Pyz/Zed/Console/ConsoleDependencyProvider.php 中,您需要为部署任务注册控制台命令插件。

use TurbineKreuzberg\Zed\DeployTasks\Communication\Console\DeployTasksCreateConsole;
use TurbineKreuzberg\Zed\DeployTasks\Communication\Console\DeployTasksExecuteConsole;

    protected function getConsoleCommands(Container $container): array
    {
        $commands = [
            // other registered console plugins ...

            new DeployTasksCreateConsole(),
            new DeployTasksExecuteConsole(),
        ];

然后,您应该在控制台命令列表中看到一个名为 deploy 的新部分。

 deploy
  deploy:tasks:create   Generate new yml file for deploy tasks
  deploy:tasks:execute  Execute all deploy tasks

使用

创建新的部署任务文件

vendor/bin/console deploy:tasks:create

这将创建一个包含当前时间戳(例如 tasks.1697540350.yml)的自动生成的名称的新YAML文件,并包含以下内容:

tasks:
# add new deploy tasks as an array to this file

# a task has to be an item with the mandatory keys 'command', 'execute_for_store' and 'execute_on'
# - the value for 'command' should be an executable shell command line (multiple commands and options possible)
# - the entries for 'execute_for_store' have to match the value of env var APPLICATION_STORE
# - the entries for 'execute_on' have to match the value of env var SHOP_ENV (dev,int,stage,prd)
- command: "some/command/to/execute --with-option --another-option-with-value foo && some/other/command"
  execute_for_store:
  - DE
  - EN
  execute_on:
  - dev
  - int
  - stage
  - prd
# to skip executing a task in a particular environment, it needs to be
# removed from the 'execute_on' list
- command: "some/other/command/to/execute/everywhere/but/production"
  execute_for_store:
  - DE
  - EN
  execute_on:
  - dev
  - int
  - stage
# to skip executing a task in a particular store, it needs to be
# removed from the 'execute_for_store' list
- command: "some/other/command/to/execute/everywhere/only/for/store-en"
  execute_for_store:
  - EN
  execute_on:
  - dev
  - int
  - stage
  - prd
# task can have additional optional keys, e.g. 'description'
- command: "yet/another/command/to/execute"
  description: "description for yet another command to execute"
  execute_for_store:
  - DE
  - EN
  execute_on:
  - dev
  - int
  - stage
  - prd

您必须明确指定任务应在哪些存储和环境中执行。
没有 '所有环境' 或 '所有存储' 选项。这应该可以防止在不应执行任务的环境或存储中意外执行任务。

执行部署任务

vendor/bin/console deploy:tasks:execute

此命令将执行所有尚未为当前环境和存储执行过的YAML文件中的部署任务。执行的任务将被记录在数据库中新的 txb_deploy_tasks 表中。其机制与Propel迁移非常相似。

致谢

许可

MIT许可(MIT)。有关更多信息,请参阅许可文件