exolnet/laravel-envoy

Automated deployment template for Laravel Envoy based on Capistrano.

v1.18.1 2023-10-26 13:53 UTC

README

Latest Stable Version Software License Build Status Total Downloads

This repository contains automated deployment template for Laravel Envoy. The deployment flow is based on Capistrano.

Installation

  1. Require this package with composer: composer require --dev exolnet/laravel-envoy:"^1.9"

  2. Create a Envoy.blade.php on your project's root with the following content: @import('exolnet/laravel-envoy')

    For a typical Laravel project, you should have a file looking like:

    @import('exolnet/laravel-envoy')
    
    @task('deploy:publish')
        cd "{{ $releasePath }}"
    
        php artisan down
    
        php artisan config:cache
        php artisan event:cache
        php artisan route:cache
        php artisan view:cache
    
        php artisan storage:link
    
        php artisan migrate --force
    
        php artisan up
    @endtask
  3. Create your deployment configuration in your Laravel project at config/deploy.php. An example config file is provided in this repository at config/deploy.php

    For a typical Laravel project, you should have a file looking like:

    <?php
    
    return [
        'name' => 'example',
    
        'default' => 'production',
    
        'environments' => [
            'production' => [
                'ssh_host'       => 'example.com',
                'ssh_user'       => 'example',
                'deploy_path'    => '/srv/example',
                'repository_url' => 'git@github.com:example/example.git',
                'linked_files'   => ['.env'],
                'linked_dirs'    => ['storage/app', 'storage/framework', 'storage/logs'],
                'copied_dirs'    => ['node_modules', 'vendor'],
            ],
        ],
    ];
  4. Enjoy!

Upgrade

Please read UPGRADE-1.x for the procedure to upgrade to version 1.x.

Usage

The following macro are available:

  • vendor/bin/envoy run setup: Setup the directory structure and repository on the remote host
  • vendor/bin/envoy run deploy --commit=abcdef: Deploy commit abcdef to the remote host
  • vendor/bin/envoy run deploy:publish --current: Run the deploy:publish task for the current release on the remote host
  • vendor/bin/envoy run releases: List available releases on the remote host
  • vendor/bin/envoy run rollback [--release=123456]: Rollback to previous release or to 123456 if specified on the remote host
  • vendor/bin/envoy run backups: List existing backups on the remote host

You can also use the native Envoy command too:

  • vendor/bin/envoy tasks: List available tasks and macros
  • vendor/bin/envoy ssh: Connect to the remote host

Note that you can also use the option --env=foo with any of the previous command to connect to an other remote define in the configuration.

Contributing

Please see CONTRIBUTING and CODE OF CONDUCT for details.

Security

SSH StrictHostKeyChecking is enforced when using git over ssh. If your remote git repository server does not support SSHFP/VerifyHostKeyDNS, you will need to manually create the known_hosts file on the remote host.

If you discover any security related issues, please email security@exolnet.com instead of using the issue tracker.

Credits

License

This code is licensed under the MIT license. Please see the license file for more information.