Update docs

This commit is contained in:
Brandon Keepers 2016-10-18 00:33:54 -05:00
parent 7343699c80
commit 574d2c599f
No known key found for this signature in database
GPG Key ID: F9533396D5FACBF6
6 changed files with 97 additions and 170 deletions

View File

@ -17,13 +17,10 @@ To test with a real GitHub repository, you'll need to create a test repository a
- **Payload URL:** Use the full `*.ngrok.io`
- **Secret:** `development`
- **Which events would you like to trigger this webhook?:** Choose **Send me everything**.
0. Create a `.probot.yml` in your repo with:
0. Create a `.probot` in your repo with:
on issues.opened then comment("Hello World! Your bot is working!");
behaviors:
- on: issues.opened
then:
comment: "Hello World! Your bot is working!"
0. Open a new issue. Your bot should post a comment (you may need to refresh to see it).
## Debugging

View File

@ -12,16 +12,9 @@ _**Heads up!** The [demo integration](https://github.com/integration/probot-demo
0. Go to the **[demo integration](https://github.com/integration/probot-demo)**, click **Install**, and then select an organization.
0. Add @probot as a collaborator with write access on your repository.
0. Create a `.probot.yml` file in your repository with the following contents. See [Configuration](docs/configuration.md) for more information on what behaviors can be built.
0. Create a `.probot` file in your repository with the following contents. See [Configuration](docs/configuration.md) for more information on what behaviors can be built.
behaviors:
- on: issues.opened
then:
comment: >
Hello @{{ sender.login }}. Thanks for inviting me to your project. Read
more about [all the things I can help you with][config]. I can't wait to
get started!
[config]: https://github.com/bkeepers/PRobot/blob/master/docs/configuration.md
on issues.opened
then comment("Hello @{{ sender.login }}. Thanks for inviting me to your project. Read more about [all the things I can help you with][config]. I can't wait to get started!\\n[config]: https://github.com/bkeepers/PRobot/blob/master/docs/configuration.md");
0. Open a new issue. @probot should post a comment (you may need to refresh to see it).

View File

@ -2,23 +2,18 @@
_**Heads up!** This yaml-based configuration syntax is not great. Ideally it will be replaced by a [proper grammar](https://github.com/bkeepers/PRobot/issues/35)._
Behaviors are configured in a file called `.probot.yml` in your repository.
Behaviors are configured in a file called `.probot` in your repository.
```yml
behaviors:
# Auto-respond to new issues and pull requests
- on:
- issues.opened
- pull_request.opened
then:
comment: "Thanks for your contribution! Expect a reply within 48 hours."
label: triage
```
# Auto-respond to new issues and pull requests
on issues.opened and pull_request.opened
then comment("Thanks for your contribution! Expect a reply within 48 hours.")
and label(triage);
# Auto-close new pull requests
- on: pull_request.opened
then:
comment: "Sorry @{{ user.login }}, pull requests are not accepted on this repository."
close: true
# Auto-close new pull requests
on pull_request.opened
then comment("Sorry @{{ user.login }}, pull requests are not accepted on this repository.")
and close;
```
## `behaviors`
@ -33,24 +28,20 @@ Behaviors are composed of:
Specifies the type of GitHub [webhook event](https://developer.github.com/webhooks/#events) that this behavior applies to:
```yml
- on: issues
```
on issues then…
```
Specifying multiple events will trigger this behavior:
You can also specify multiple events to trigger this behavior:
```yml
- on:
- issues
- pull_request
```
on issues and pull_request then…
```
Many events also have an `action` (e.g. `created` for the `issue` event), which can be referenced with dot notation:
```yml
- on:
- issues.labeled
- issues.unlabeled
```
on issues.labeled and issues.unlabeled then…
```
[Webhook events](https://developer.github.com/webhooks/#events) include:
@ -84,7 +75,7 @@ TODO: document actions
Only preform the actions if theses conditions are met.
_Heads up! There are not any `when` conditions implemented yet. _
_Heads up! There are not any `when` conditions implemented yet._
### `then`
@ -92,86 +83,74 @@ _Heads up! There are not any `when` conditions implemented yet. _
Comments can be posted in response to any event performed on an Issue or Pull Request. Comments use [mustache](https://mustache.github.io/) for templates and can use any data from the event payload.
```yml
then:
comment: >
Hey @{{ user.login }}, thanks for the contribution!
```
 then comment("Hey @{{ user.login }}, thanks for the contribution!");
```
#### `close`
Close an issue or pull request.
```yml
then:
close: true
```
… then close;
```
#### `open`
Reopen an issue or pull request.
```yml
then:
open: true
```
… then open;
```
#### `lock`
Lock conversation on an issue or pull request.
```yml
then:
lock: true
```
… then lock;
```
#### `unlock`
Unlock conversation on an issue or pull request.
```yml
then:
unlock: true
```
… then unlock;
```
#### `label`
Add labels
```yml
then:
label: bug
```
… then label(bug);
```
#### `unlabel`
Add labels
```yml
then:
unlabel: needs-work
label: waiting-for-review
```
… then unlabel("needs-work") and label("waiting-for-review");
```
#### `assign`
```yml
then:
assign: hubot
```
… then assign(hubot);
```
#### `unassign`
```yml
then:
unassign: defunkt
```
… then unassign(defunkt);
```
#### `react`
```yml
then:
react: heart # or +1, -1, laugh, confused, heart, hooray
```
… then react(heart); # or +1, -1, laugh, confused, heart, hooray
```
---

View File

@ -5,97 +5,57 @@ _**Heads up!** these examples include configuration options that are aspirationa
Here are some examples of interesting things you can do by combining these components.
```yml
behaviors:
# Post welcome message for new contributors
- on:
- issues.opened
- pull_request.opened
when:
first_time_contributor: true # plugins could implement conditions like this
then:
comment:
from_file: .github/NEW_CONTRIBUTOR_TEMPLATE.md
# Post welcome message for new contributors
on issues.opened and pull_request.opened
when first_time_contributor # plugins could implement conditions like this
then comment(file(".github/NEW_CONTRIBUTOR_TEMPLATE.md"));
# Auto-close new pull requests
- on:
- pull_request.opened
then:
comment: "Sorry @{{ user.login }}, pull requests are not accepted on this repository."
close: true
# Auto-close new pull requests
on pull_request.opened
then comment("Sorry @{{ user.login }}, pull requests are not accepted on this repository.")
and close;
# Close issues with no body
- on:
- issues.opened
when:
payload:
body:
matches: /^$/
then:
comment: "Hey @{{ user.login }}, you didn't include a description of the problem, so we're closing this issue."
# Close issues with no body
on issues.opened
when payload.body matches /^$/
then comment("Hey @{{ user.login }}, you didn't include a description of the problem, so we're closing this issue.");
# @mention watchers when label added
- on: *.labeled
then:
comment:
# TODO: figure out syntax for loading watchers from file
message: "Hey {{ mentions }}, you wanted to know when the `{{ payload.label.name }}` label was added."
# @mention watchers when label added
on *.labeled then
# TODO: figure out syntax for loading watchers from file
comment("Hey {{ mentions }}, you wanted to know when the `{{ payload.label.name }}` label was added.");
# Assign a reviewer for new bugs
- on: pull_request.labeled
- when:
- labeled: bug
then:
- assign:
random:
from_file: OWNERS
# Assign a reviewer for new bugs
on pull_request.labeled
when labeled(bug)
then assign(random(file(OWNERS)));
# Perform actions based on content of comments
- on: issue_comment.opened
when:
payload:
issue.body:
matches: /^@probot assign @(\w+)$/
then:
assign: {{ matches[0] }}
- on: issue_comment.opened
when:
payload:
issue.body:
matches: /^@probot label @(\w+)$/
then:
label: {{ matches[0] }}
# Perform actions based on content of comments
on issue_comment.opened
when payloadissue.body matches /^@probot assign @(\w+)$/
then assign({{ matches[0] }})
# Close stale issues and pull requests
- on: *.labeled
when:
label: needs-work
state: open
then:
delay:
after: 7 days
close: true
on issue_comment.opened
when payload.issue.body matches /^@probot label @(\w+)$/
then label({{ matches[0] }})
# Tweet when a new release is created
- on: release.published
then:
tweet: "Get it while it's hot! {{ repository.name }} {{ release.name }} was just released! {{ release.html_url }}"
# Close stale issues and pull requests
on *.labeled
when labeled("needs-work") and state("open")
then delay(7 days) and close
# Assign a reviewer issues or pull requests with a label
- on:
- issues.opened
- pull_request.opened
- issues.labeled
- pull_request.labeled
when:
label: security
then:
assign:
random:
from_team: security-first-responders
# Tweet when a new release is created
on release.published
then tweet("Get it while it's hot! {{ repository.name }} {{ release.name }} was just released! {{ release.html_url }}")
# Label state transitions
# TODO
# Assign a reviewer issues or pull requests with a label
on issues.opened and pull_request.opened and issues.labeled and pull_request.labeled
when labeled(security)
then assign(random(members(security-first-responders));
# Apply label based on changed files
# TODO
# Label state transitions
# TODO
# Apply label based on changed files
# TODO
```

View File

@ -1,12 +1,11 @@
// Assign one or more users to an issue or pull request.
//
// ```yml
// - then:
// # Assign a single user
// assign: bkeeepers
// ```
// # Assign a single user
// then assign(bkeepers);
//
// # Assign multiple users
// assign: [bkeeepers, benbalter]
// # Assign multiple users
// then assign(bkeepers, benbalter);
// ```
//

View File

@ -1,12 +1,11 @@
// Unassign one or more users from an issue or pull request.
//
// ```yml
// - then:
// # Unassign a single user
// unassign: bkeeepers
// ```
// # Unassign a single user
// then unassign(bkeepers);
//
// # Unassign multiple users
// unassign: [bkeeepers, benbalter]
// # Unassign multiple users
// then unassign(bkeepers, benbalter);
// ```
//