codex / git
Codex 插件 - 支持基于标签/分支的 Github/Bitbucket 集成与同步(自动 webhook 或手动)。
dev-master / 2.1.x-dev
2019-04-27 13:27 UTC
Requires
- codex/core: ~2.0
- graham-campbell/bitbucket: ~4.1
- graham-campbell/github: ~7.3
- graham-campbell/manager: ~4.0
- league/oauth2-client: ~2.3
- league/oauth2-github: ~2.0
- php-http/guzzle6-adapter: 1.1.*
- stevenmaguire/oauth2-bitbucket: ~3.0
- vierbergenlars/php-semver: 3.0.*
Suggests
- codex/algolia-search: Integrates algolia search into codex (~2.0)
- codex/auth: Provides authentication using oauth providers (socialite) to restrict project access (~2.0)
- codex/blog: Provides blogging capability with categories containing posts (~2.0)
- codex/comments: Adds comments to your documents like Disqus or create your own adapter (~2.0)
- codex/filesystems: Adds a collection of common filesystem adapters. These can be used by your projects. (~2.0)
- codex/packagist: Integrates Packagist information links and macros in your projects (~2.0)
- codex/phpdoc: Integrates PHPDoc documentation, links and macros in your projects (~2.0)
- codex/sitemap: Generates a sitemap.xml (~2.0)
This package is auto-updated.
Last update: 2024-09-12 00:14:11 UTC
README
Git
Git 插件允许您的 Codex 项目从任何 Bitbucket/Github 仓库获取文档。可以通过手动同步或使用 webhook 的自动同步。
例如,您在 Github 上有一个名为 docs 的目录,其中包含所有文档。Git 插件可以将仓库的分支/标签同步到本地项目的修订版。还可以创建一个指向 Codex 项目的 Github webhook,使 Codex 自动同步最新更改。
安装
composer require codex/git php artisan codex:addon enable codex/git php artisan vendor:publish --provider="Codex\Git\GitAddonServiceProvider"
项目配置
您可以将 Git 插件配置添加到项目的 config.php 文件中。
[
// ...
'git' => [
'remotes' => [
'main' => [
// The connection key to use (as defined at the top of this file)
'connection' => '',
// The owner (organisation or username)
'owner' => '',
// The repository name
'repository' => '',
// repository url
'url' => 'https://bitbucket.org/%s/%s',
'document_url' => 'https://bitbucket.org/%s/%s/src/%s',
'webhook' => [
// Enable webhook support. Configure it in Github/Bitbucket.
// This will automaticly sync your project every time a 'push' event occurs
// This also requires you to configure queues properly (by using for example, redis with supervisord)
'enabled' => false,
// Github webhooks allow a 'secret' that has to match. Put it in here
'secret' => null,
],
],
],
'syncs' => [
[
'remote' => 'main',
// Branches to sync
'branches' => [], //[ 'master']
// Version (tags) constraints makes one able to define ranges and whatnot
// * || 1.x || >=2.5.0 || 5.0.0 - 7.2.3'
'versions' => null,
'skip' => [
'patch_versions' => false,
'minor_versions' => false,
],
'clean' => [
],
'copy' => [
'docs',
'docs/ ** /*.md',
'docs/index.md' => 'index.md',
'README.md' => 'index.md',
],
],
],
'links' => [
'enabled' => false,
'remote' => 'main',
'map' => [
'edit_page' => 'layout.toolbar.right', // push attribute to array (default)
],
'links' => [
'edit_page' => [
'component' => 'c-button',
'borderless' => true,
'target' => '_black',
'type' => 'toolbar',
/** git.connection_config is a get modifier in Document @see \Codex\Git\GitAddonServiceProvider */
// 'icon' => '%remote.connection.driver%',
'children' => 'Edit Page',
/** git_links.document_url is a get modifier in Document @see \Codex\Git\GitAddonServiceProvider */
// 'href' => '%remote.document_url%',
],
],
],
],
];
全局配置
位于 config/codex-git.php
return [ 'connections' => [ 'bitbucket_oauth' => [ 'driver' => 'bitbucket', 'method' => 'oauth', 'key' => env('CODEX_GIT_BITBUCKET_KEY', 'your-key'), 'secret' => env('CODEX_GIT_BITBUCKET_SECRET', 'your-secret'), ], 'bitbucket_password' => [ 'driver' => 'bitbucket', 'method' => 'password', 'username' => env('CODEX_GIT_BITBUCKET_USERNAME', 'your-username'), 'password' => env('CODEX_GIT_BITBUCKET_PASSWORD', 'your-password'), ], 'github_token' => [ 'driver' => 'github', 'method' => 'token', 'token' => env('CODEX_GIT_GITHUB_TOKEN', 'your-token'), ], 'github_password' => [ 'driver' => 'github', 'method' => 'password', 'username' => env('CODEX_GIT_GITHUB_USERNAME', 'your-username'), 'password' => env('CODEX_GIT_GITHUB_PASSWORD', 'your-password'), ], 'github_app' => [ 'driver' => 'github', 'clientId' => 'your-client-id', 'clientSecret' => 'your-client-secret', 'method' => 'application', ], 'github_jwt' => [ 'driver' => 'github', 'token' => 'your-jwt-token', 'method' => 'jwt', ], ], // ... ];
同步
手动同步
php artisan codex:git:sync [project]
自动(webhook)同步
要使用自动同步
- 自动同步依赖于一个正常工作的 Laravel 队列驱动。请确保您已配置并启动它。
- 您需要在 Github/Bitbucket 仓库中添加一个 webhook。webhook URL 应与
codex.git.webhook.{bitbucket,github}路由 URL 相同。您可以使用php artisan route:list来获取它。
版权/许可证
版权 2019 Robin Radic - MIT 许可证