Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save folbert/4f1737d16444cd4402dfb71893a39fb5 to your computer and use it in GitHub Desktop.
Save folbert/4f1737d16444cd4402dfb71893a39fb5 to your computer and use it in GitHub Desktop.
<?php
/**
* Deploy for Bedrock with Sage9 on Homestead.
* Loosely based on https://github.com/zorca/wp-deploy/blob/master/deploy.php.
*/
namespace Deployer;
require 'recipe/common.php';
// Load config
inventory('deploy.yml');
// Set the name of the theme folder
set('echocrate_settings__theme_name', 'NAME_OF_THEME_FOLDER');
// Add paths to all custom composer files that you have in the project
set('echocrate_settings__additional_composer_paths', [
'/web/app/themes/' . get('echocrate_settings__theme_name'),
]);
set('keep_releases', 3);
// Files and dirs to delete after deploy is done
set('clear_paths', [
'*.md',
'.editorconfig',
'.env.example',
'.gitignore',
'.git',
'after.sh',
'deploy.php',
'deploy.yml',
'Homestead.yml', // Remove if not using Homestead
'Homestead.yaml', // Remove if not using Homestead
'Vagrantfile',
'web/.htaccess',
]);
set('theme_path', 'web/app/themes/' . get('echocrate_settings__theme_name'));
// Bedrock shared dirs
set('shared_dirs', [
'web/app/uploads',
'web/app/languages',
]);
// Bedrock shared files
set('shared_files', [
'.env',
'web/.htaccess',
]);
// Bedrock writable dirs
set('writable_dirs', [
'web/app/uploads',
'web/app/languages',
]);
// Name of release folder
set('release_name', function () {
return (string) run('date +%Y%m%d-%H%M%S');
});
task('echocrate:run_additional_composer', function() {
$additional_composer_paths = get('echocrate_settings__additional_composer_paths');
foreach($additional_composer_paths AS $additional_composer_path) {
run('cd {{ release_path }}' . $additional_composer_path . ' && {{bin/composer}} {{composer_options}}');
}
});
task('echocrate:theme:build_and_upload_assets', function() {
runLocally('cd ' . get('theme_path') . ' && yarn run build:production');
upload(get('theme_path') . '/dist', '{{release_path}}/' . get('theme_path') . '');
});
task('echocrate:theme:build_and_upload_pot', function() {
runLocally('cd ' . get('theme_path') . ' && yarn pot');
run('rm -rf {{release_path}}/' . get('theme_path') . '/resources/languages');
upload(get('theme_path') . '/resources/languages', '{{release_path}}/' . get('theme_path') . '/resources');
});
task('echocrate:cleanup', function() {
run('rm {{release_path}}/composer.json');
run('rm {{release_path}}/composer.lock');
});
/**
* Main task
*/
task('deploy', [
'deploy:info',
'deploy:prepare',
'deploy:lock',
'deploy:release',
'deploy:update_code',
'echocrate:run_additional_composer',
'deploy:clear_paths',
'deploy:shared',
'deploy:vendors',
'deploy:writable',
'echocrate:theme:build_and_upload_assets',
//'echocrate:theme:build_and_upload_pot',
'deploy:symlink',
'deploy:unlock',
'echocrate:cleanup',
'cleanup',
]);
after('deploy', 'success');
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment