承接 node-link/cakephp-git-deploy 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

node-link/cakephp-git-deploy

Composer 安装命令:

composer require node-link/cakephp-git-deploy

包简介

Plugin to operate automatic git-pull server with CakePHP 3 (Using WebHook from GitHub, GitLab and Bitbucket)

README 文档

README

Plugin to operate automatic git-pull server with CakePHP 3 (Using WebHook from GitHub, GitLab and Bitbucket)

Requirements

  • CakePHP 3.5 or later
  • PHP 5.6 or later

Installation

1. Install plugin

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require node-link/cakephp-git-deploy

2. Load plugin

Please load the plugin manually as follows:

<?php
// In src/Application.php. Requires at least 3.6.0
use Cake\Http\BaseApplication;

class Application extends BaseApplication
{
    public function bootstrap()
    {
        parent::bootstrap();

        // Load the plugin
        $this->addPlugin('NodeLink/GitDeploy');
    }
}

Prior to 3.6.0, you should use Plugin::load():

<?php
// In config/bootstrap.php

use Cake\Core\Plugin;

Plugin::load('NodeLink/GitDeploy', ['bootstrap' => true, 'routes' => true]);

Or, use bin/cake to load the plugin as follows:

bin/cake plugin load -b -r NodeLink/GitDeploy

Configuration

Edit config/.env or config/app.php.

The full default configuration is as follows:

<?php
return [
    'GitDeploy' => [
        'enable' => filter_var(env('GIT_DEPLOY_ENABLE', false), FILTER_VALIDATE_BOOLEAN),
        'token' => env('GIT_DEPLOY_TOKEN', 'secret'),
        'branch' => env('GIT_DEPLOY_BRANCH', 'master'),
        'git_path' => env('GIT_DEPLOY_GIT_PATH', '/usr/bin/git'),
        'composer_path' => env('GIT_DEPLOY_COMPOSER_PATH', '/usr/local/bin/composer')
    ],
];

It is recommended to add following items to config/.env.

export GIT_DEPLOY_ENABLE="true"
export GIT_DEPLOY_TOKEN="__TOKEN__"
export GIT_DEPLOY_BRANCH="master"
export GIT_DEPLOY_GIT_PATH="/usr/bin/git"
export GIT_DEPLOY_COMPOSER_PATH="/usr/local/bin/composer"
export COMPOSER_HOME="/var/www"

It may not work unless COMPOSER_HOME is set correctly.

Settings

GitHub

In your repository, navigate to Settings → Webhooks → Add webhook, and use the following settings:

  • Payload URL: https://example.com/git-deploy
  • Content type: application/json
  • Secret: The value of GIT_DEPLOY_TOKEN in config/.env
  • Which events would you like to trigger this webhook?: 🔘 Just the push event
  • Active: ☑️

Click "Add webhook" to save your settings, and the script should start working.

Example screenshot showing GitHub webhook settings

GitLab

In your repository, navigate to Settings → Integrations, and use the following settings:

Click "Add webhook" to save your settings, and the script should start working.

Example screenshot showing GitLab webhook settings

Bitbucket

In your repository, navigate to Settings → Webhooks → Add webhook, and use the following settings:

Click "Save" to save your settings, and the script should start working.

Example screenshot showing Bitbucket webhook settings

Trouble Shooting

If execution is not successful, please refer to logs/error.log and logs/debug.log.

Details of the error at the time of execution may be listed in some cases.

Permissions

When it does not work well, in many cases, there is a problem with permissions.

Please set so that the web server user (www, www-data, apache, etc...) can git pull and composer install.

It is suggested this be accomplished by changing the repository group to the web server user's and giving the group write permissions:

  1. Open a terminal to the directory containing the repository on the server.
  2. run sudo chown -R yourusername:webserverusername project-dir/ to change the group of the repo.
  3. run sudo chmod -R g+s project-dir/ to make the group assignment inherited for new files/dirs.
  4. run sudo chmod -R 775 project-dir/ to set read & write for both owner and group.

SSH

Generate an SSH key and add it to your account so that git pull can be run without a password.

Reporting Issues

If you have a problem with the GitDeploy plugin, please send a pull request or open an issue on GitHub.

Also, I would appreciate it if you contribute to updating README.md file.

node-link/cakephp-git-deploy 适用场景与选型建议

node-link/cakephp-git-deploy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 52 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 09 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「git」 「deploy」 「cakephp」 「webhook」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 node-link/cakephp-git-deploy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 node-link/cakephp-git-deploy 我们能提供哪些服务?
定制开发 / 二次开发

基于 node-link/cakephp-git-deploy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 52
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-26