项目作者: probot

项目描述 :
A Probot extension to easily share configs between repositories.
高级语言: JavaScript
项目地址: git://github.com/probot/probot-config.git
创建时间: 2017-10-19T15:53:35Z
项目社区:https://github.com/probot/probot-config

开源协议:BSD 3-Clause "New" or "Revised" License

下载


This project has been moved to Probot core

This project has been merged into Probot itself as part of the core context.config helper. Any future development takes place there.

Probot: Config

Downloads version
License
Build Status

A Probot extension to easily share configs between
repositories.

Setup

Just put common configuration keys in a common repository within your
organization. Then reference this repository from config files with the same
name.

  1. # octocat/probot-settings:.github/test.yaml
  2. shared1: will be merged
  3. shared2: will also be merged
  4. # octocat/repo1:.github/test.yaml
  5. _extends: probot-settings
  6. other: AAA
  7. # octocat/repo2:.github/test.yaml
  8. _extends: probot-settings
  9. shared2: overrides shared2
  10. other: BBB
  11. # octocat/repo3:.github/test.yaml
  12. other: CCC # standalone, does not extend other configs

Configs are deeply-merged. Nested objects do not have to be redefined
completely. This is accomplished using deepmerge. When using probot-config in an app, you can pass options through to deepmerge.

You can also reference configurations from other organizations:

  1. _extends: other/probot-settings
  2. other: DDD

Additionally, you can specify a specific path for the configuration by
appending a colon after the project.

  1. _extends: probot-settings:.github/other_test.yaml
  2. other: FFF

Inherited configurations are in the exact same location within the
repositories.

  1. # octocat/repo1:.github/test.yaml
  2. _extends: .github
  3. other: GGG
  4. # octocat/.github:test.yaml
  5. other: HHH

Additionally, if there is no config file, but there is a repo in the org named
.github, it will be used as a base repository.

  1. # octocat/repo1:.github/test.yaml <-- missing!
  2. # octocat/.github:.github/test.yaml
  3. other: III

Recipes

These recipes are specific to usage of the .github repo name, which is the
recommended place to store your configuration files. Within the .github repository,
your configuration must live in a .github/ folder.

An opt-in pattern

You may want to create a configuration that other projects in your org inherit
from on an explicit opt-in basis. Example:

  1. # octocat/.github:.github/_test.yaml
  2. shared1: Will be inherited by repo1 and not repo2
  3. # octocat/repo1:.github/test.yaml
  4. # Inherits from octocat/.github:_test.yaml
  5. _extends: .github:_test.yaml
  6. # octocat/repo3:.github/test.yaml <--missing!
  7. # Is not merged with another config.

An opt-out pattern

Alternatively, you may want to default to the config in your .github project
and occasionally opt-out. Example:

  1. # octocat/.github:.github/test.yaml
  2. shared1: Will be inherited by repo1 and not repo2
  3. # octocat/repo1:.github/test.yaml <-- missing!
  4. # Uses octocat/.github:test.yaml instead
  5. # octocat/repo3:.github/test.yaml <-- either empty or populated
  6. # Will not inherit shared1, since no _extends field is specified

Usage

  1. const getConfig = require('probot-config');
  2. module.exports = robot => {
  3. robot.on('push', async context => {
  4. // Will look for 'test.yml' inside the '.github' folder
  5. const config = await getConfig(context, 'test.yml');
  6. });
  7. };

Development

  1. # Install dependencies
  2. npm install
  3. # Run the bot
  4. npm start
  5. # Run test watchers
  6. npm run test:watch

We use prettier for auto-formatting and
eslint as linter. Both tools can automatically fix a lot
of issues for you. To invoke them, simply run:

  1. npm run fix

It is highly recommended to use VSCode and install the suggested extensions.
They will configure your IDE to match the coding style, invoke auto formatters
every time you save and run tests in the background for you. No need to run the
watchers manually.