phenriquelima/continuousdelivery

dev-main 2022-09-13 12:51 UTC

This package is auto-updated.

Last update: 2024-09-13 16:57:19 UTC


README

此组件通过发送HTTP请求提供应用程序部署的常规类。设置github webhook post请求到您的应用程序的路由并运行代码以更新本地仓库。

先决条件

在OS GNU/Linux Debian 11上测试过(docker镜像 php:8.0-apache

  • 服务器上必须安装Composer和Git

功能

使用此组件,您可以运行三个阶段来交付您的应用程序

  1. 从您的服务器仓库运行安全的git pull以更新源代码
  2. 运行composer install或compose update
  3. 运行迁移,例如:'php artisan migrate 或 vendor/bin/phinx migrate'

安装

composer require phenriquelima/continuousdelivery:dev-main

使用方法

如果您正在使用Laravel或任何框架或路由组件,请根据以下说明创建路由并从该路由运行回调或控制器方法

  1. 定义您的静态baseURL变量(必须是应用程序根URL)
  2. 使用以下四个参数创建ContinuousDelivery类实例
    • 基础路径URL(命令将在此处执行)
    • 更新您的仓库的安全URL
    • 运行迁移的代码
    • 安装依赖的代码
use PHenriqueLima\ContinuousDelivery\Controller\ContinuousDelivery;

 Route::get('/pull', function(){
   
    $continuousDelivery = new ContinuousDelivery(
        '/var/www/vacinacao/',
        'git pull https://phenriquelima:yourSecureTokenProvideByGithub@github.com/AccountName/RepositoryName',
        'php artisan migrate',
        'composer install --no-autoloader'
        );
    
});
  1. 如果您想查看组件配置运行
var_dump($continuousDelivery->settings());
  • 此方法返回设置状态的数组
  1. 如果您想禁用更新执行中的某些三个阶段
  • ContinuousDelivery::instance()::$databaseMigrations = false;
  • ContinuousDelivery::instance()::$dependencyManager = false;
  • ContinuousDelivery::instance()::$updateRepository = false;

警告

  • 确保您的应用程序用户有权限写入仓库
  • 配置您的根路径应用程序