Skip to content

Instantly share code, notes, and snippets.

@grohiro
Last active September 4, 2017 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grohiro/3733be33da4a36f363a135c13530c4c7 to your computer and use it in GitHub Desktop.
Save grohiro/3733be33da4a36f363a135c13530c4c7 to your computer and use it in GitHub Desktop.
The recipe of deployer to upload dotenv file.
<?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