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,12 +17,9 @@ To test with a real GitHub repository, you'll need to create a test repository a
- **Payload URL:** Use the full `*.ngrok.io` - **Payload URL:** Use the full `*.ngrok.io`
- **Secret:** `development` - **Secret:** `development`
- **Which events would you like to trigger this webhook?:** Choose **Send me everything**. - **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:
behaviors: on issues.opened then comment("Hello World! Your bot is working!");
- 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). 0. Open a new issue. Your bot should post a comment (you may need to refresh to see it).

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. 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. 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
- 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");
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
0. Open a new issue. @probot should post a comment (you may need to refresh to see it). 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)._ _**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 # Auto-respond to new issues and pull requests
- on: on issues.opened and pull_request.opened
- issues.opened then comment("Thanks for your contribution! Expect a reply within 48 hours.")
- pull_request.opened and label(triage);
then:
comment: "Thanks for your contribution! Expect a reply within 48 hours."
label: triage
# Auto-close new pull requests # Auto-close new pull requests
- on: pull_request.opened on pull_request.opened
then: then comment("Sorry @{{ user.login }}, pull requests are not accepted on this repository.")
comment: "Sorry @{{ user.login }}, pull requests are not accepted on this repository." and close;
close: true
``` ```
## `behaviors` ## `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: 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: on issues and pull_request then…
- issues
- pull_request
``` ```
Many events also have an `action` (e.g. `created` for the `issue` event), which can be referenced with dot notation: Many events also have an `action` (e.g. `created` for the `issue` event), which can be referenced with dot notation:
```yml ```
- on: on issues.labeled and issues.unlabeled then…
- issues.labeled
- issues.unlabeled
``` ```
[Webhook events](https://developer.github.com/webhooks/#events) include: [Webhook events](https://developer.github.com/webhooks/#events) include:
@ -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. 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:  then comment("Hey @{{ user.login }}, thanks for the contribution!");
comment: >
Hey @{{ user.login }}, thanks for the contribution!
``` ```
#### `close` #### `close`
Close an issue or pull request. Close an issue or pull request.
```yml ```
then: … then close;
close: true
``` ```
#### `open` #### `open`
Reopen an issue or pull request. Reopen an issue or pull request.
```yml ```
then: … then open;
open: true
``` ```
#### `lock` #### `lock`
Lock conversation on an issue or pull request. Lock conversation on an issue or pull request.
```yml ```
then: … then lock;
lock: true
``` ```
#### `unlock` #### `unlock`
Unlock conversation on an issue or pull request. Unlock conversation on an issue or pull request.
```yml ```
then: … then unlock;
unlock: true
``` ```
#### `label` #### `label`
Add labels Add labels
```yml ```
then: … then label(bug);
label: bug
``` ```
#### `unlabel` #### `unlabel`
Add labels Add labels
```yml ```
then: … then unlabel("needs-work") and label("waiting-for-review");
unlabel: needs-work
label: waiting-for-review
``` ```
#### `assign` #### `assign`
```yml ```
then: … then assign(hubot);
assign: hubot
``` ```
#### `unassign` #### `unassign`
```yml ```
then: … then unassign(defunkt);
unassign: defunkt
``` ```
#### `react` #### `react`
```yml ```
then: … then react(heart); # or +1, -1, laugh, confused, heart, hooray
react: heart # or +1, -1, laugh, confused, heart, hooray
``` ```
--- ---

View File

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

View File

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

View File

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