Files
probot/docs/github-api.md
Brandon Keepers 34e8bddfdd Merge remote-tracking branch 'origin/master' into plugin-to-app
* origin/master:
  The Slack chat channel on the Internet machine
  Clean up link to slack channel
  Add link to slack channel
  Adds a line break
  add test to ensure deprecation occurs
  add version for deprecation to console.warn and inline comment
  it's on the same tab
  annoying space 💢
  bot -> app
  0 -> 1 silly markdown
  Create CONTRIBUTING.md
  Add linter extend to package.json
  clarify REST API
  use settings.yml
  Update development.md
  Fix urls to example apps
  Fix link to example GitHub profile
  Bumps webhook dep and adds webhookPath config
2017-08-22 18:29:44 -05:00

1.7 KiB

next
next
docs/http.md

Interacting with GitHub

Probot uses GitHub Apps. An app is a first-class actor on GitHub, like a user (e.g. @defunkt) or an organization (e.g. @github). The app is given access to a repository or repositories by being "installed" on a user or organization account and can perform actions through the API like commenting on an issue or creating a status.

context.github is an authenticated GitHub client that can be used to make API calls. It is an instance of the github Node.js module, which wraps the GitHub REST API and allows you to do almost anything programmatically that you can do through a web browser.

Here is an example of an autoresponder app that comments on opened issues:

module.exports = robot => {
  robot.on('issues.opened', async context => {
    // `context` extracts information from the event, which can be passed to
    // GitHub API calls. This will return:
    //   {owner: 'yourname', repo: 'yourrepo', number: 123, body: 'Hello World!}
    const params = context.issue({body: 'Hello World!'})

    // Post a comment on the issue
    return context.github.issues.createComment(params);
  });
}

See the full API docs to see all the ways you can interact with GitHub. Some API endpoints are not available on GitHub Apps yet, so check which ones are available first.