tombroucke/otomaties-deployer

There is no license information available for the latest version (1.10.0) of this package.

Deploy Bedrock & Sage

1.10.0 2024-12-11 12:42 UTC

README

Installation

composer require tombroucke/otomaties-deployer --dev

Example deploy.php file

<?php
namespace Deployer;

require_once __DIR__ . '/vendor/autoload.php';
require 'contrib/cachetool.php';

$dotenv = \Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();

require 'vendor/tombroucke/otomaties-deployer/deploy.php';

/** Config */
set('web_root', 'web');
set('application', '');
set('repository', '');
set('sage/theme_path', get('web_root') . '/app/themes/themename');
set('sage/build_command', 'build --clean --flush'); // build --clean for bud, build:production for mix

/** Hosts */
host('production')
    ->set('hostname', 'ssh###.webhosting.be')
    ->set('url', '')
    ->set('remote_user', 'examplebe')
    ->set('branch', 'main')
    ->set('deploy_path', '/data/sites/web/examplebe/app/main');

host('staging')
    ->set('hostname', 'ssh###.webhosting.be')
    ->set('url', '')
    ->set('basic_auth_user', $_SERVER['BASIC_AUTH_USER'] ?? '')
    ->set('basic_auth_pass', $_SERVER['BASIC_AUTH_PASS'] ?? '')
    ->set('remote_user', 'examplebe')
    ->set('branch', 'staging')
    ->set('deploy_path', '/data/sites/web/examplebe/app/staging');

/** Install theme dependencies */
after('deploy:vendors', 'sage:vendors');

/** Push theme assets */
after('deploy:update_code', 'sage:compile_and_upload_assets');

/** Write revision to file */
after('deploy:update_code', 'otomaties:write_revision_to_file');

/** Reload Combell */
after('deploy:symlink', 'combell:reloadPHP');

/** Clear OPcode cache */
after('deploy:symlink', 'cachetool:clear:opcache');

/** Cache ACF fields */
after('deploy:symlink', 'acorn:acf_cache');

/** Reload cache & preload */
after('deploy:symlink', 'wp_rocket:clear_cache');

/** Reload cache & preload */
after('deploy:symlink', 'wp_rocket:preload_cache');

/** Remove unused themes */
after('deploy:cleanup', 'cleanup:unused_themes');

/** Unlock deploy */
after('deploy:failed', 'deploy:unlock');

WooCommerce

/** Update WooCommerce tables */
after('deploy:symlink', 'woocommerce:update_database');

WordPress cache

/** Update WooCommerce tables */
after('deploy:symlink', 'wordpress:clear_cache');

Extra commands

Enable basic auth on host:

dep auth:password_protect_stage staging

Create bedrock .env file

dep bedrock:create_env staging

Add repository authentication to remote server

dep composer:add_remote_repository_authentication

Setup Wordfence firewall for Bedrock / deployer

dep wordfence:firewall_setup

Add .htaccess rules for security

dep otomaties:htaccess_rules

Set default Wordfence configuration

dep wordfence:default_configuration