edwines/updater-bundle

Symfony2 Bundle,允许通过服务钩子(POST数据)更新git仓库

安装: 59

依赖: 0

建议者: 0

安全: 0

星标: 2

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

v1.0.0 2013-07-25 12:12 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:14:18 UTC


README

Total Downloads Latest Stable Version Latest Unstable Version

此bundle允许在生产环境中更新仓库;使用一些git托管系统提供的git服务钩子(如GitHub)。目前支持的提供商有

  • GitHub
  • Bitbucket

但你可以构建你自己的自定义提供商。

需求

生产服务器需要安装并配置git以连接提供商。此外,Symfony项目的仓库需要对Web用户(通常命名为www-data)有写权限。

安装

步骤1:下载EdwinesUpdaterBundle

在composer.json中添加以下依赖项

{
    "require": {
        "edwines/updater-bundle": "1.0.*",
    }
}

现在通过运行以下命令让composer下载bundle

$ php composer.phar update edwines/updater-bundle

步骤2:启用bundle

在kernel中启用bundle

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Edwines\UpdaterBundle\EdwinesUpdaterBundle(),
    );
}

步骤3:配置bundle

默认情况下,您不需要设置配置。但如果您想更改默认值,请按照以下说明操作

该bundle将仓库目录设置为%kernel.root_dir%/../,要编辑它只需设置repo_path

# app/config/config.yml

edwines_updater:
    repo_path: /project/repository/path/

默认情况下,提供商是GitHub,如果您想使用Bitbucket

# app/config/config.yml

edwines_updater:
    provider: Edwines\UpdaterBundle\Provider\Bitbucket

步骤4:添加路由

如果您想拥有所有路由(更新系统的路由和查看git状态的路由)

# app/config/routing.yml

ed_updater:
    resource: "@EdwinesUpdaterBundle/Resources/config/routing/updater.yml"
    prefix:   /my-updater-prefix

或者如果只想添加更新项目的路由

# app/config/routing.yml

ed_updater:
    resource: "@EdwinesUpdaterBundle/Resources/config/routing/hook.yml"
    prefix:   /my-hook-prefix

步骤5:向您的提供商添加POST服务

现在,您需要在提供商中添加一个新的服务钩子(请参阅GitHub帮助)。您的钩子URL将是http://my-domain.com/my-updater-prefix/hook/或如果您配置为仅使用钩子URL:http://my-domain.com/my-hook-prefix/

工作原理

当bundle收到提供商的payload时,它会比较修改的分支是否与当前项目相同,然后自动运行命令git pull origin {current_branch},最后清除缓存。

您可以在http://my-domain.com/my-updater-prefix/的URL中查看项目的git状态和最后提交的记录。