Skip to content

Instantly share code, notes, and snippets.

@mabasic
Last active Jul 6, 2021
Embed
What would you like to do?
Envoy common features with Slack notifications. See http://laravel.com/docs/5.0/envoy for more info.
@servers(['web' => 'username@domain.com -p 1234'])
@setup
$project_name = 'Project Name';
$project_url = 'http://project-domain.com/';
$project_root = '/www/project/web';
$slack_hook = 'your-slack-hook-url';
$slack_channel = '#channel';
@endsetup
@task('put_app_up', ['on' => 'web'])
cd {{ $project_root }}
php artisan up
@endtask
@task('put_app_down', ['on' => 'web'])
cd {{ $project_root }}
php artisan down
@endtask
@task('pull_latest_changes', ['on' => 'web'])
cd {{ $project_root }}
git pull origin
@endtask
@task('install_dependencies', ['on' => 'web'])
cd {{ $project_root }}
composer install --prefer-source --no-interaction --no-dev
@endtask
@task('clear_cache', ['on' => 'web'])
cd {{ $project_root }}
php artisan cache:clear
@endtask
@macro('update')
put_app_down
pull_latest_changes
install_dependencies
put_app_up
@endmacro
@after
@slack($slack_hook, $slack_channel, "Envoy task $task ran on <$project_url|[$project_name]>")
@endafter
@bigoper

This comment has been minimized.

Copy link

@bigoper bigoper commented Nov 4, 2016

Hey,

On line 50 when executing @slack, I get the slack msg, but the $task is empty...
When I run the following:
@slack('https://hooks.slack.com/services/XXXXXXXXXXXXX','#alerts')
I do get the task name in the default msg.
"demo-user ran the [testDomain] task"

Can you assist?
Thanks!

@mabasic

This comment has been minimized.

Copy link
Owner Author

@mabasic mabasic commented Jan 29, 2017

@bigoper Maybe change "Envoy task $task ran on <$project_url|[$project_name]>" to "Envoy task {$task} ran on <{$project_url}|[{$project_name}]>".

Hope it helps!

@Ryouzanki

This comment has been minimized.

Copy link

@Ryouzanki Ryouzanki commented May 30, 2017

Hello, I have tried with {$task} and it does not work either. I really cant find what's wrong...

@jminkler

This comment has been minimized.

Copy link

@jminkler jminkler commented Jun 26, 2019

@finished worked for us

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment