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 are composed of:
on
- webhook events to listen tofilter
(optional) - conditions to determine if the actions should be performed.- actions to take in response to the event
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')
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('- [ ]'))
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!');
Deletes the comment for the issue_comment
, commit_comment
, and pull_request_review_comment
events.
.deleteComment();
Close an issue or pull request.
.close();
Reopen an issue or pull request.
.open();
Lock conversation on an issue or pull request.
.lock();
Unlock conversation on an issue or pull request.
.unlock();
Add labels
.label('bug');
Add labels
.unlabel('needs-work').label('waiting-for-review');
.assign('hubot');
.unassign('defunkt');
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']
});
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');
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.