stekel / laravel-deploy

帮助部署特定仓库到远程机器的实用命令。

v3.1.9 2023-03-08 00:38 UTC

This package is auto-updated.

Last update: 2024-09-08 03:58:00 UTC


README

帮助部署特定仓库到远程机器的实用命令

安装

使用 composer 安装:composer require stekel/laravel-deploy

创建配置文件:php artisan vendor:publish --provider="stekel\LaravelDeploy\Laravel\Providers\LaravelDeployServiceProvider"

创建站点配置类

<?php

namespace App;

use stekel\LaravelDeploy\Site;

class SampleSite extends Site
{
    public function prod()
    {
        $this->ssh('192.168.1.100, admin, password, function ($connection) {
            $connection->command('git reset --hard');
            $connection->command('git pull');
            $connection->command('composer install --optimize-autoloader --no-dev');
            $connection->command('php artisan migrate');
            $connection->command('php artisan cache:clear');
            $connection->command('php artisan config:cache');
            $connection->command('php artisan route:cache');
            $connection->command('php artisan view:cache');
        });
    }
}

在配置中引用该类

// ...   
    'sites' => [
        'sample-site' => \App\SampleSite::class,
    ],
// ... 

在部署时引用站点/环境

// stekel:deploy {site} {environment}
stekel:deploy sample-site prod