konstantinn/laravel-github-deploy

轻松将laravel项目部署到github。

0.1.1 2020-01-29 17:14 UTC

This package is auto-updated.

Last update: 2024-09-29 05:09:08 UTC


README

Latest Version on Packagist MIT Licensed Total Downloads

关于

此包允许您在将更新发布到GitHub后自动化发布到您的服务器。

安装

composer require konstantinn/laravel-github-deploy

前往您的远程服务器并设置带有用户名和密码的git origin仓库地址

git remote set-url origin https://USERNAME:PASSWORD@github.com/USERNAME/REPOSITORY.git

发布配置文件deploy.php

php artisan vendor:publish --provider="Konstantinn\LaravelGitHubDeploy\DeployServiceProvider"

默认情况下,日志写入到文件storage/logs/deploy.log,但您可以在配置文件deploy.php中更改路径

打开VerifyCsrfToken中间件并将路由'/deploy'添加到except受保护属性中

class VerifyCsrfToken extends Middleware
{
    /**
     * Indicates whether the XSRF-TOKEN cookie should be set on the response.
     *
     * @var bool
     */
    protected $addHttpCookie = true;

    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        '/deploy'
    ];
}

前往您的GitHub仓库并创建具有Payload Url: https://SITE.DOMEN/deploy 的webhook
填写Secret字段并复制此数据并将其粘贴到.env文件中

APP_DEPLOY_SECRET=GIH_HUB_HOOK_SECRET  

检查最近交付部分中的webhook请求

全部搞定!

部署命令

默认情况下,部署运行以下命令

'commands' => [
    'git pull',
    'composer install --no-interaction --no-dev --prefer-dist',
    'php artisan migrate --force',
],

但您可以在配置文件deploy.php中添加或修改命令。

贡献者