Skip to content

Instantly share code, notes, and snippets.

@ac00perw
Last active August 28, 2018 14:28
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 ac00perw/078b8af9c85ca96e5ee4129c400c66c2 to your computer and use it in GitHub Desktop.
Save ac00perw/078b8af9c85ca96e5ee4129c400c66c2 to your computer and use it in GitHub Desktop.
Envoy deployer (rsync set to dry run & Wordpress excludes)
@servers(['local' => ['127.0.0.1'], 'production' => ['admin@domain.com']])
@setup
$vars=[
'localdir' => '',
'remote' => "",
'remotedir' => "",
'rsyncflags' => "-n --exclude 'Envoy*' --exclude '.git' --exclude '.gitignore' --exclude 'wp-config.php' --exclude 'wp-content' --exclude 'wp-config.php'",
];
$count = 0;
@endsetup
@story('deploy')
checkvariables
help
deployer
@endstory
@story('deploycontent')
checkvariables
help
deploy-contents
@endstory
@story('synccontent')
checkvariables
help
sync-contents
@endstory
@task('checkvariables', ['on' => 'local'])
@foreach($vars as $var)
@if( empty($var) )
{{ $count +=1 }}
@endif
@endforeach
@if($count > 0)
echo 'Please define local variables';
exit 1;
@else
echo '--- Variable Definitions ---\nremote = {{ $vars['remote'] }}'
echo 'remotedir = {{ $vars['remotedir'] }}'
echo 'localdir = {{ $vars['localdir'] }}'
echo 'rsyncflags = {{ $vars['rsyncflags'] }}'
@endif
echo ' === '
@endtask
@task('help', ['on' => 'local'])
echo "envoy run deploy : Rsync {{ $vars['localdir'] }} -->> remote"
echo "envoy run deploy-content : Rsync /wp-content -->> remote /wp-content"
echo "envoy run sync-content : Grab remote /wp-content"
echo " === "
@endtask
@task('deployer', ['on' => 'local', 'confirm' => true])
echo 'rsync {{ $vars['remote'] }}:{{ $vars['remotedir'] }}'
cd {{ $vars['localdir'] }}
rsync -nrvz {{ $rsyncflags }} ./ {{ $vars['remote'] }}:{{ $vars['remotedir'] }}
@endtask
@task('deploy-contents', ['on' => 'local', 'confirm' => true])
echo 'rSync local ./wp-content to remote ./wp-content'
cd {{ $vars['localdir'] }}
echo 'rsync -rvz ./wp-content/ {{ $vars['remote'] }}:{{ $vars['remotedir'] }}'
rsync -nrvz ./wp-content/ {{ $vars['remote'] }}:{{ $vars['remotedir'] }}wp-content
@endtask
@task('sync-contents', ['on' => 'local', 'confirm' => true])
echo 'Grab remote ./wp-content'
cd {{ $vars['localdir'] }}
echo 'rsync -r {{ $vars['remote'] }}:{{ $vars['remotedir'] }}wp-content/ ./wp-content'
rsync -nr {{ $vars['remote'] }}:{{ $vars['remotedir'] }}wp-content/ ./wp-content
@endtask
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment