Skip to content

Instantly share code, notes, and snippets.

@keyurshah
Forked from AugustMiller/deploy.php
Created April 15, 2019 05:19
Show Gist options
  • Save keyurshah/a81a8c65f559fbac7ac4e7366acb2567 to your computer and use it in GitHub Desktop.
Save keyurshah/a81a8c65f559fbac7ac4e7366acb2567 to your computer and use it in GitHub Desktop.
Boilerplate Deployer config for a Craft 3 project https://deployer.org
<?php
namespace Deployer;
require 'recipe/composer.php';
// Project name
set('application', 'my-project');
// Project repository
set('repository', '[email protected]:organization/repo.git');
// Use Git cache to speed up cloning new code:
set('git_cache', true);
// Allow multiplexing
set('ssh_multiplexing', true);
// Shared files/dirs between deploys
add('shared_files', [
'.env',
'config/license.key'
]);
add('shared_dirs', [
'storage',
'web/cpresources',
'web/your-asset-folder'
]);
// Composer Settings
set('composer_options', '{{composer_action}} --no-dev --optimize-autoloader --no-progress --no-interaction --ignore-platform-reqs');
// Writable dirs by web server
add('writable_dirs', []);
// Hosts
inventory('hosts.yml');
// Tasks
desc('Custom Pipeline: Build local assets');
task('build:render', function () {
runLocally('npm run build');
});
after('deploy:update_code', 'build:render');
desc('Custom Pipeline: Sync built assets to remote server');
task('build:sync', function () {
upload('web/assets/css', '{{release_path}}/web/assets', ['options' => ['--recursive']]);
upload('web/assets/js', '{{release_path}}/web/assets', ['options' => ['--recursive']]);
});
after('deploy:update_code', 'build:sync');
// Re-trigger this, as it isn't part of the default `composer` recipe:
after('deploy:vendors', 'deploy:writable');
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
set('allow_anonymous_stats', false);
staging:
hostname: staging.yourdomain.com
stage: staging
roles: web
user: deploy
forwardAgent: true
deploy_path: /var/www/my-project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment