probot

  • Version 12.1.1
  • Published
  • 712 kB
  • 35 dependencies
  • ISC license

Install

npm i probot
yarn add probot
pnpm add probot

Overview

A framework for building GitHub Apps to automate and improve your workflow

Index

Variables

variable ProbotOctokit

const ProbotOctokit: any;

    Functions

    function createNodeMiddleware

    createNodeMiddleware: (
    appFn: ApplicationFunction,
    { probot, webhooksPath }: MiddlewareOptions
    ) => any;

      function createProbot

      createProbot: ({ overrides, defaults, env }?: CreateProbotOptions) => Probot;
      • Merges configuration from defaults/environment variables/overrides and returns a Probot instance. Finds private key using [@probot/get-private-key](https://github.com/probot/get-private-key).

        Parameter defaults

        default Options, will be overwritten if according environment variable is set

        Parameter overrides

        overwrites defaults and according environment variables

        Parameter env

        defaults to process.env

        See Also

        • https://probot.github.io/docs/configuration/

      function run

      run: (
      appFnOrArgv: ApplicationFunction | string[],
      additionalOptions?: AdditionalOptions
      ) => Promise<Server>;
      • Parameter appFnOrArgv

        set to either a probot application function: (app) => { ... } or to process.argv

      Classes

      class Context

      class Context<E extends WebhookEvents = WebhookEvents> {}
      • The context of the event that was triggered, including the payload and helpers for extracting information can be passed to GitHub API calls.

        ```js module.exports = app => { app.on('push', context => { context.log.info('Code was pushed to the repo, what should we do with it?'); }); }; ```

        {octokit} octokit - An Octokit instance {payload} payload - The webhook event payload {log} log - A pino instance

      constructor

      constructor(event: any, octokit: any, log: any);

        property id

        id: string;

          property isBot

          readonly isBot: boolean;
          • Returns a boolean if the actor on the event was a bot. {boolean}

          property log

          log: any;

            property name

            name: any;

              property octokit

              octokit: any;

                property payload

                payload: any;

                  method config

                  config: <T>(
                  fileName: string,
                  defaultConfig?: T,
                  deepMergeOptions?: any
                  ) => Promise<T | null>;
                  • Reads the app configuration from the given YAML file in the .github directory of the repository.

                    For example, given a file named .github/config.yml:

                    close: true
                    comment: Check the specs on the rotary girder.

                    Your app can read that file from the target repository:

                    // Load config from .github/config.yml in the repository
                    const config = await context.config('config.yml')
                    if (config.close) {
                    context.octokit.issues.comment(context.issue({body: config.comment}))
                    context.octokit.issues.edit(context.issue({state: 'closed'}))
                    }

                    You can also use a defaultConfig object:

                    // Load config from .github/config.yml in the repository and combine with default config
                    const config = await context.config('config.yml', {comment: 'Make sure to check all the specs.'})
                    if (config.close) {
                    context.octokit.issues.comment(context.issue({body: config.comment}));
                    context.octokit.issues.edit(context.issue({state: 'closed'}))
                    }

                    Config files can also specify a base that they extend. deepMergeOptions can be used to configure how the target config, extended base, and default configs are merged.

                    For security reasons, configuration is only loaded from the repository's default branch, changes made in pull requests from different branches or forks are ignored.

                    If you need more lower-level control over reading and merging configuration files, you can context.octokit.config.get(options), see https://github.com/probot/octokit-plugin-config.

                    Parameter fileName

                    Name of the YAML file in the .github directory

                    Parameter defaultConfig

                    An object of default config options

                    Parameter deepMergeOptions

                    Controls merging configs (from the [deepmerge](https://github.com/TehShrike/deepmerge) module) Configuration object read from the file

                  method issue

                  issue: <T>(object?: T) => { issue_number: any } & { owner: any; repo: any } & T;
                  • Return the owner, repo, and issue_number params for making API requests against an issue. The object passed in will be merged with the repo params.

                    const params = context.issue({body: 'Hello World!'})
                    // Returns: {owner: 'username', repo: 'reponame', issue_number: 123, body: 'Hello World!'}

                    Parameter object

                    Params to be merged with the issue params.

                  method pullRequest

                  pullRequest: <T>(
                  object?: T
                  ) => { pull_number: any } & { owner: any; repo: any } & T;
                  • Return the owner, repo, and pull_number params for making API requests against a pull request. The object passed in will be merged with the repo params.

                    const params = context.pullRequest({body: 'Hello World!'})
                    // Returns: {owner: 'username', repo: 'reponame', pull_number: 123, body: 'Hello World!'}

                    Parameter object

                    Params to be merged with the pull request params.

                  method repo

                  repo: <T>(object?: T) => { owner: any; repo: any } & T;
                  • Return the owner and repo params for making API requests against a repository.

                    const params = context.repo({path: '.github/config.yml'})
                    // Returns: {owner: 'username', repo: 'reponame', path: '.github/config.yml'}

                    Parameter object

                    Params to be merged with the repo params.

                  class Probot

                  class Probot {}

                    constructor

                    constructor(options?: Options);

                      property auth

                      auth: (
                      installationId?: number,
                      log?: any
                      ) => Promise<InstanceType<typeof ProbotOctokit>>;

                        property log

                        log: any;

                          property on

                          on: any;

                            property onAny

                            onAny: any;

                              property onError

                              onError: any;

                                property version

                                static version: string;

                                  property version

                                  version: string;

                                    property webhooks

                                    webhooks: any;

                                      method defaults

                                      static defaults: <S extends Constructor<any>>(
                                      this: S,
                                      defaults: Options
                                      ) => (new (...args: any[]) => { [x: string]: any }) & S;

                                        method load

                                        load: (appFn: ApplicationFunction | ApplicationFunction[]) => Promise<void>;

                                          method receive

                                          receive: (event: any) => Promise<void>;

                                            class Server

                                            class Server {}

                                              constructor

                                              constructor(options?: ServerOptions);

                                                property expressApp

                                                expressApp: any;

                                                  property log

                                                  log: any;

                                                    property probotApp

                                                    probotApp: Probot;

                                                      property version

                                                      static version: string;

                                                        property version

                                                        version: string;

                                                          method load

                                                          load: (appFn: ApplicationFunction) => Promise<void>;

                                                            method router

                                                            router: (path?: string) => any;

                                                              method start

                                                              start: () => Promise<HttpServer>;

                                                                method stop

                                                                stop: () => Promise<unknown>;

                                                                  Interfaces

                                                                  interface Options

                                                                  interface Options {}

                                                                    property appId

                                                                    appId?: number | string;

                                                                      property baseUrl

                                                                      baseUrl?: string;

                                                                        property githubToken

                                                                        githubToken?: string;

                                                                          property host

                                                                          host?: string;

                                                                            property log

                                                                            log?: Logger;

                                                                              property logLevel

                                                                              logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';

                                                                                property logMessageKey

                                                                                logMessageKey?: string;

                                                                                  property Octokit

                                                                                  Octokit?: typeof ProbotOctokit;

                                                                                    property port

                                                                                    port?: number;

                                                                                      property privateKey

                                                                                      privateKey?: string;

                                                                                        property redisConfig

                                                                                        redisConfig?: Redis.RedisOptions | string;

                                                                                          property secret

                                                                                          secret?: string;

                                                                                            Type Aliases

                                                                                            type ApplicationFunctionOptions

                                                                                            type ApplicationFunctionOptions = {
                                                                                            getRouter?: (path?: string) => express.Router;
                                                                                            [key: string]: unknown;
                                                                                            };

                                                                                              Package Files (9)

                                                                                              Dependencies (35)

                                                                                              Dev Dependencies (32)

                                                                                              Peer Dependencies (0)

                                                                                              No peer dependencies.

                                                                                              Badge

                                                                                              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/probot.

                                                                                              • Markdown
                                                                                                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/probot)
                                                                                              • HTML
                                                                                                <a href="https://www.jsdocs.io/package/probot"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>