Deployer: Only deploy if a tag has been supplied

Created on 4 Sep 2018  路  2Comments  路  Source: deployphp/deployer

| Q | A
| ----------------- | ---
| Issue Type | Question
| Deployer Version | 6.2.0
| Local Machine OS | Mac OS 10.13.2
| Remote Machine OS | N/A

Description

So I'm absolutely loving deployer and I'm just working out my production deployment setup (currently only using it for a staging environment). I'm happy to deploy my master branch to staging, so running dep deploy staging works great for me.

However, on my production environment, I'd only like to allow the deploy if a tag has been supplied, so dep deploy production --tag=1.1.4 would be fine, however if I tried running dep deploy production - I would like the deploy to fail. Is this possible?

Chris.

docs needed

Most helpful comment

Thanks @antonmedv. I've looked into it a bit and written a task, maybe this will be of use to others -

// Check we are deploying with a tag on production
task('validate:tag', function () {
    if (!input()->getOption('tag')) {
        throw new \Exception(
            'You must supply a valid tag when deploying to ' . 
            input()->getArgument('stage')
        );
    }
})->onStage('production');
before('deploy', 'validate:tag');

At least this now prevents accidental deployments to my production :) Deployer is awesome - and so flexible!

All 2 comments

Yes, Just add extra task and check if tag is setted. Otherwise throw an exception.

Thanks @antonmedv. I've looked into it a bit and written a task, maybe this will be of use to others -

// Check we are deploying with a tag on production
task('validate:tag', function () {
    if (!input()->getOption('tag')) {
        throw new \Exception(
            'You must supply a valid tag when deploying to ' . 
            input()->getArgument('stage')
        );
    }
})->onStage('production');
before('deploy', 'validate:tag');

At least this now prevents accidental deployments to my production :) Deployer is awesome - and so flexible!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brunodevel picture brunodevel  路  3Comments

osbulbul picture osbulbul  路  3Comments

jolipixel picture jolipixel  路  4Comments

krve picture krve  路  4Comments

dima-stefantsov picture dima-stefantsov  路  5Comments