Skip to content

Instantly share code, notes, and snippets.

Last active Jan 23, 2022
What would you like to do?
Deployer recipe for Craft CMS 3 projects.
namespace Deployer;
require 'recipe/common.php';
// Project name
set('application', '');
// Project repository
set('repository', '');
// Shared files/dirs between deploys
set('shared_files', [
set('shared_dirs', [
// Writable dirs by web server
set('writable_dirs', [
// Set the worker process user
set('http_user', 'worker');
// Set the default deploy environment to production
set('default_stage', 'production');
// Disable multiplexing
set('ssh_multiplexing', false);
// Tasks
// Upload build assets
task('upload', function () {
upload(__DIR__ . "/public/assets/", '{{release_path}}/public/assets/');
//upload(__DIR__ . "/public/service-worker.js", '{{release_path}}/public/service-worker.js');
desc('Execute migrations');
task('craft:migrate', function () {
run('{{release_path}}/craft migrate/up');
// Hosts
// Production Server(s)
host('', '', '')
->set('deploy_path', '/websites/{{application}}')
->set('branch', 'master')
// Staging Server
->set('deploy_path', '/websites/{{application}}')
->set('branch', 'develop')
// Group tasks
desc('Deploy your project');
task('deploy', [
'upload', // Custom task to upload build assets
// [Optional] Run migrations
after('deploy:vendors', 'craft:migrate');
// [Optional] If deploy fails automatically unlock
after('deploy:failed', 'deploy:unlock');
// Run with '--parallel'
// dep deploy --parallel
Copy link

duikb00t commented Feb 4, 2021

Thanks mtwalsh!

Copy link

mtwalsh commented Feb 4, 2021

@duikb00t You're welcome, glad it's useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment