Solicit

Solicit requests reviewers from your slack channel automatically!

It works by listening for labels on your repo(s) from the github api, and posting a message into a specified slack channel which allows people to assign themselves to the pull request.

This was developed at the third annual Optimal Workshop hackathon.

Installation

  1. Add an outgoing webhook to your github repository, with the 'pull requests' event type enabled

NB: the 'Secret' value here will become your github_secret value

  1. [Create a slack app] for your team NB: note your 'Webhook URL' and 'Verification token' here to use as 'slack_webhook_url and slack_secret later

  2. Configure the gem on your app

    # Gemfile
    gem 'solicit'
    
    # routes.rb
    mount Solicit::Engine, at: '/solicit'
    
    # app/initializers/solicit.rb
    

required

Solicit.slack_webhook_url = "" Solicit.github_api_token = "" Solicit.contributors_map = { timmy: { handle: "TimmyTeaco", name: "Timmy", emoji: "dolphin" } jimmy: { handle: "JimmyBoy", name: "Jimmy", emoji: "whale" } }

optional

Solicit.labels_map = { "review me": "#reviewers" } # default is { "go" => "#general" } Solicit.slack_username = "ReviewBot" Solicit.slack_secret = "" Solicit.github_secret = "" Solicit.needs_more_assignees = proc do |github_response, label| label == "swarm" end


More info on each option is below:

##### slack_webhook_url (required)

The url of the webhook provided by your slack app

https://api.slack.com/incoming-webhooks

##### github_api_token (required)

A personal API token with access to your github repo.

https://github.blog/2013-05-16-personal-api-tokens/

##### contributors_map (required)

A hash which maps slack usernames to github usernames.
You can optionally provide a custom emoji which will appear when this
person claims a PR.

##### labels_map (optional)

A hash which maps github label names to the slack channel in which they should appear. By default, any PR that has the 'go' label placed on it will notify the #general channel.

##### slack_username (optional)

The username which should appear as the message sender. By default, the bot is named 'Solicit'

##### slack_secret (optional)

A signing token from slack to secure requests to your app.
You can read more about setting up secure slack webhooks here:

https://api.slack.com/docs/verifying-requests-from-slack

##### github_secret (optional)

A signing token from github to secure requests to your app.
You can read more about setting up secure github webhooks here:

https://developer.github.com/webhooks/securing/

##### needs_more_assignees (optional)

Some organizations may have rules around how many assignees should be
put on a given PR. If so, you can define a method which returns whether
a PR should continue to accept reviewers.
(TODO explain this better)

## Development

#### Installation

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).


#### Running tests

To run the test suite, run
```bash
rake test

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/optimalworkshop/solicit. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.