5.8 KiB
Configuration
Workflows are configured in a file called .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 tofilter(optional) - conditions to determine if the actions should be performed.then- actions to take in response to the event
on
Specifies the type of GitHub webhook event that this behavior applies to:
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')
Webhook events include:
- commit_comment - Any time a Commit is commented on.
- create - Any time a Branch or Tag is created.
- delete - Any time a Branch or Tag is deleted.
- deployment - Any time a Repository has a new deployment created from the API.
- deployment_status - Any time a deployment for a Repository has a status update from the API.
- fork - Any time a Repository is forked.
- gollum - Any time a Wiki page is updated.
- issue_comment - Any time a comment on an issue is created, edited, or deleted.
- issues - Any time an Issue is assigned, unassigned, labeled, unlabeled, opened, edited, closed, or reopened.
- member - Any time a User is added as a collaborator to a Repository.
- membership - Any time a User is added or removed from a team.Organization hooks only.
- page_build - Any time a Pages site is built or results in a failed build.
- public - Any time a Repository changes from private to public.
- pull_request_review_comment - Any time a comment on a Pull Request's unified diff is created, edited, or deleted (in the Files Changed tab).
- pull_request_review - Any time a Pull Request Review is submitted.
- pull_request - Any time a Pull Request is assigned, unassigned, labeled, unlabeled, opened, edited, closed, reopened, or synchronized (updated due to a new push in the branch that the pull request is tracking).
- push - Any Git push to a Repository, including editing tags or branches. Commits via API actions that update references are also counted. This is the default event.
- repository - Any time a Repository is created, deleted, made public, or made private.
- release - Any time a Release is published in a Repository.
- status - Any time a Repository has a status update from the API
- team_add - Any time a team is added or modified on a Repository.
- watch - Any time a User stars a Repository.
TODO: document actions
filter
Only preform the actions if the function returns true. The event is passed as an argument to the function and attributes of the webhook payload.
.filter(event => event.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!");
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');
See examples for ideas of behaviors you can implement by combining these configuration options.