Deployer: New stage() func proposal

Created on 8 Dec 2017  路  8Comments  路  Source: deployphp/deployer

What about adding a new function for manipulating stages?

stage('production', function () {
    set('deploy_path', '...');
    host('domain.com')
        ->roles(['app']);
});
stage('staging', function () {
    set('deploy_path', '...');
    inventory('./inventory/staging.yml');
});

All 8 comments

I think it's a great idea. It actually makes more sense to make the stage / environment a root element. You could do many things such as:

  • associate a specific branch to a stage
  • add custom tasks for a stage (deployment notification only for production for example)
  • have different variables set for each environment
  • a lot more I cannot think of right now

It is how PM2 Deployment works, and I believe it has only advantages. It is a great feature! Let me know if you need any help with implementation or tests, I'll be happy to help.

What about having separate file for each stage?

|- deploy.php
|- app
    |- deploy
        |- staging.php
        |- production.php

deploy.php

set('stages', __DIR__ . '/app/deploy');
set('default_stage', 'staging');

production.php

set('branch', 'master');
host('production.com');

Personally I like to have all my deployment configuration in a single file. Since I have other config files (ex: phpunit, CI script, Dockerfile, Composer, gulp, npm, ...), I find it easier to have one file per tool. But my deployment scripts are usually quite simple, maybe this would be a good idea for projects with more complex scripts?

Do you like it?

stage('production', function () {
    set('branch', 'production');
    host('ec2-32-47-157-121.eu-west-1.compute.amazonaws.com');
    host('ec2-52-37-137-111.ap-southeast-1.compute.amazonaws.com');
});

stage('staging', function () {
    set('branch', 'development');
    host('beta.project.com');
});

I would prefer something like

stage('production')
    ->set('branch', 'production')
    ->host('ec2-32-47-157-121.eu-west-1.compute.amazonaws.com')
    ->host('ec2-52-37-137-111.ap-southeast-1.compute.amazonaws.com');
});

stage('development')
    ->set('branch', 'development')
    ->host('beta.project.com');
});

to have it like the host() api which is also IDE friendly and allows autocompletion etc.

@staabm okay, how to do it:

stage('production', function () {
    set('branch', 'production');
    host('ec2-32-47-157-121.eu-west-1.compute.amazonaws.com')
        ->set('param', 'value');
    host('ec2-52-37-137-111.ap-southeast-1.compute.amazonaws.com');
});

ok, I see.

I decided to remove the stage in the flavor of roles which eventually the same, but more functional. See #1904 for progress.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lsv picture lsv  路  4Comments

exts picture exts  路  3Comments

k-solnushkin picture k-solnushkin  路  5Comments

jolipixel picture jolipixel  路  4Comments

dima-stefantsov picture dima-stefantsov  路  5Comments