Options
All
  • Public
  • Public/Protected
  • All
Menu

The context of the event that was triggered, including the payload and helpers for extracting information can be passed to GitHub API calls.

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

{github} github - A GitHub API client

property

{payload} payload - The webhook event payload

property

{logger} log - A logger

Hierarchy

  • Context

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

Properties

event

event: any

github

github: GitHubAPI

id

id: number

log

payload

Accessors

isBot

isBot:

Returns a boolean if the actor on the event was a bot.

type

{boolean}

Methods

config

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

    example
    Contents of .github/config.yml.
    close: true
    comment: Check the specs on the rotary girder.
    
    example
    App that reads from .github/config.yml.
    // Load config from .github/config.yml in the repository
    const config = await context.config('config.yml')
    
    if (config.close) {
      context.github.issues.comment(context.issue({body: config.comment}))
      context.github.issues.edit(context.issue({state: 'closed'}))
    }
    
    example
    Using 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.github.issues.comment(context.issue({body: config.comment}));
      context.github.issues.edit(context.issue({state: 'closed'}))
    }
    

    Type parameters

    • T

    Parameters

    • fileName: string

      Name of the YAML file in the .github directory

    • Optional defaultConfig: T

      An object of default config options

    Returns Promise<null | T>

    Configuration object read from the file

issue

  • issue<T>(object?: T): object & object & T
  • Return the owner, repo, and number params for making API requests against an issue or pull request. The object passed in will be merged with the repo params.

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

    Type parameters

    • T

    Parameters

    • Optional object: T

      Params to be merged with the issue params.

    Returns object & object & T

repo

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

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

    Type parameters

    • T

    Parameters

    • Optional object: T

      Params to be merged with the repo params.

    Returns object & T

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc