Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample Envoy tasks for a Laravel project. - http://laravel.com/docs/ssh - https://github.com/laravel/envoy
* -A in SSH enables agent forwarding.
* -p 2122 is not needed if you use the default port of 22.
* Replace SSH_USER and example.com with your own values.
* Example run: $ envoy run deploy_demo
* --no-scripts because Laravel composer.json's post-install-cmd includes optimize, which is already done by php artisan dump-autoload
@servers(['test' => '-A -p 2122 -l user test.example.com', 'prod' => '-A -p 2122 -l user example.com'])
@task('install_test', ['on' => ['test']])
cd project
git clone git@bitbucket.org:example/example.com.git .
composer install -n --no-dev --no-scripts
php artisan dump-autoload
php artisan migrate
chmod -R 0777 public/upload app/storage
@endtask
@task('install_prod', ['on' => ['prod']])
cd project
git clone git@bitbucket.org:example/example.com.git .
composer install -n --no-dev --no-scripts
php artisan dump-autoload
php artisan migrate
chmod -R 0777 public/upload app/storage
@endtask
@task('deploy_test', ['on' => ['test']])
cd project
git pull origin
composer install -n --no-dev --no-scripts
php artisan dump-autoload
php artisan migrate
@endtask
@task('deploy_prod', ['on' => ['prod']])
cd project
git pull origin
composer install -n --no-dev --no-scripts
php artisan dump-autoload
php artisan migrate
@endtask
@lozadaOmr

This comment has been minimized.

Copy link

@lozadaOmr lozadaOmr commented Mar 21, 2015

@halilim
If I didn't included ssh-key in machine when doing git pull/fetch/push I need to enter my password. Will it be possible to just have a variable, let the script get the value from it?

@halilim

This comment has been minimized.

Copy link
Owner Author

@halilim halilim commented Jun 4, 2015

Sorry for replying late, it looks like GitHub doesn't notify Gist owners for new comments.

Well, if you use the -A parameter on the ssh command (defined in @servers) and if you have your SSH agent running properly, then your local key would automatically be forwarded to your production server, and then to GitHub. Or you can generate a deploy-only key in the production server and enter it as a deploy key into the project settings at GitHub/Bitbucket.

Some other methods along with these are explained here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.