| Q | A
| ----------------- | ---
| Issue Type | Question
| Deployer Version | 6.2.0
| Local Machine OS | Mac OS 10.13.2
| Remote Machine OS | N/A
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.
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!
Most helpful comment
Thanks @antonmedv. I've looked into it a bit and written a task, maybe this will be of use to others -
At least this now prevents accidental deployments to my production :) Deployer is awesome - and so flexible!