Last active
September 4, 2017 04:08
-
-
Save grohiro/3733be33da4a36f363a135c13530c4c7 to your computer and use it in GitHub Desktop.
The recipe of deployer to upload dotenv file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Deployer; | |
// deployer dotenv:upload stage | |
// deployer dotenv:dump | |
// deployer dotenv:export | |
// deployer dotenv stage | |
set('dotenv_path', '{{deploy_path}}/shared/.env'); | |
task('dotenv', ['dotenv:upload']); | |
// Uplaod a .env.{stage} file. | |
task('dotenv:upload', function () { | |
$stage = get('stage'); | |
$src = "config/.env.${stage}"; | |
if (!file_exists($src)) { | |
throw new \Exception("File not found: $src"); | |
} | |
$dest = '{{dotenv_path}}'; | |
upload($src, $dest); | |
}); | |
task('dotenv:export', function () { | |
run('export $(cat {{dotenv_path}} | xargs)'); | |
}); | |
task('dotenv:dump', function () { | |
// Read .env | |
writeln(run('cat {{dotenv_path}}')); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment