Skip to content

Latest commit

 

History

History
192 lines (130 loc) · 3.61 KB

configuration.md

File metadata and controls

192 lines (130 loc) · 3.61 KB

Configuration

Workflows are configured in a file called .github/probot.js in your repository.

// Auto-respond to new issues and pull requests
on('issues.opened', 'pull_request.opened')
  .comment('Thanks for your contribution! Expect a reply within 48 hours.')
  .label('triage');

// Auto-close new pull requests
on('pull_request.opened')
  .comment('Sorry @{{ user.login }}, pull requests are not accepted on this repository.')
  .close();

Workflows

Workflows are composed of:

  • on - webhook events to listen to
  • filter (optional) - conditions to determine if the actions should be performed.
  • actions to take in response to the event

on

Specifies the type of GitHub webhook event that this behavior applies to.

See also Probot documentation.

on('issues')

You can also specify multiple events to trigger this behavior:

on('issues', 'pull_request')

Many events also have an action (e.g. created for the issue event), which can be referenced with dot notation:

on('issues.labeled', 'issues.unlabeled')

filter

Only perform the actions if the function returns true. The context is passed as an argument to the function and attributes of the webhook payload.

.filter(context => context.payload.issue.body.includes('- [ ]'))

comment

Comments can be posted in response to any event performed on an Issue or Pull Request. Comments use mustache for templates and can use any data from the event payload.

.comment('Hey @{{ user.login }}, thanks for the contribution!');

deleteComment

Deletes the comment for the issue_comment, commit_comment, and pull_request_review_comment events.

.deleteComment();

close

Close an issue or pull request.

.close();

open

Reopen an issue or pull request.

.open();

lock

Lock conversation on an issue or pull request.

.lock();

unlock

Unlock conversation on an issue or pull request.

.unlock();

label

Add labels

.label('bug');

unlabel

Add labels

.unlabel('needs-work').label('waiting-for-review');

assign

.assign('hubot');

unassign

.unassign('defunkt');

createIssue

Create a new issue defined as a JSON Object. The title and body fields are required.

.createIssue({
  title: 'Issue Title',
  body: 'Issue Body',
  assignees: ['bkeepers'],
  labels: ['question']
});

The body of the issue can be generated from the contents of a template file within the repository by invoking the contents function.

.createIssue({
  title: 'Issue Title',
  body: contents('.github/NEW_ISSUE_TEMPLATE.md'),
  assignees: ['bkeepers'],
  labels: ['question']
});

include

Loads a configuration from another file.

include('.github/bot/issues.js');
include('.github/bot/releases.js');

You can also include configuration from another repository.

include('user/repo:path.js#branch');

contents

Retrieves the contents of the repository and passes them to any plugin method.

on('issues.opened')
  .comment(contents('.github/NEW_ISSUE_TEMPLATE.md'));

This also supports fetching contents from another repository

on('issues.opened')
  .comment(contents('atom/configs:.github/NEW_ISSUE_TEMPLATE.md'));

See examples for ideas of behaviors you can implement by combining these configuration options.