Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rootstrap/pull_requests_to_slack
Send Github pull request notifications to Slack
https://github.com/rootstrap/pull_requests_to_slack
bot github-hooks hacktoberfest notifications pull-requests ruby slack
Last synced: 3 days ago
JSON representation
Send Github pull request notifications to Slack
- Host: GitHub
- URL: https://github.com/rootstrap/pull_requests_to_slack
- Owner: rootstrap
- License: mit
- Created: 2018-04-05T14:21:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-19T01:56:01.000Z (about 1 year ago)
- Last Synced: 2024-04-16T14:31:02.238Z (7 months ago)
- Topics: bot, github-hooks, hacktoberfest, notifications, pull-requests, ruby, slack
- Language: Ruby
- Homepage: https://rootstrap.com
- Size: 215 KB
- Stars: 21
- Watchers: 11
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Rootstrap Pull request to Slack
[![Build Status](https://travis-ci.org/rootstrap/pull_requests_to_slack.svg?branch=master)](https://travis-ci.org/rootstrap/pull_requests_to_slack)
[![Maintainability](https://api.codeclimate.com/v1/badges/9e5ed337285c4b6f7882/maintainability)](https://codeclimate.com/github/rootstrap/pull_requests_to_slack/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/9e5ed337285c4b6f7882/test_coverage)](https://codeclimate.com/github/rootstrap/pull_requests_to_slack/test_coverage)Send Github pull request notifications to Slack.
- Each time a PR is created in your organization it will send a message to a specific Slack channel with a link to the PR and its technology emoji assigned.
- When the PR is merged it will add a merged reaction emoji.- You can add ``` \slack `This is a small pr @slack_user` ``` at the end of the PR's description to add a message to the notification and to notify specific Slack users.
Make sure to use ``` ` ` ``` in the message in case the Slack user name is the same as someone's GitHub name, so the github user is not notified.
- It will not send a notification if the PR is a draft.
- It will remove the notification if the PR has an `ON HOLD` label and resend the notification when the label is removed.## Installation
1. Clone this repo
2. Install PostgreSQL in case you don't have it
3. Create your `database.yml` and `application.yml` files. There are sample files in `/config`
4. `bundle install`
5. Generate a secret key with `rake secret` and paste this value into the `application.yml`.
6. Fill the `SLACK_API_TOKEN` and `SLACK_BOT_TOKEN` in `application.yml`.
To get the credentials: log in to https://api.slack.com/apps, select your application and then click OAuth Tokens & Redirect URLs. `SLACK_API_TOKEN` is the `OAuth Access Token` and `SLACK_BOT_TOKEN` is `Bot User OAuth Access Token`
6. `rails db:create`
7. `rails db:migrate`
8. `rails db:seed` # this will create an admin with [email protected]:password
9. `npm install -g ngrok` Install Ngrok
10. `rspec` and make sure all tests pass
11. `rails s`
12. You are ready!## How to test the webhook locally?
- Create a dummy repository in github with a couple branches.
- Run server: `rails s -p 3001`
- In another terminal run ngrok: `ngrok http 3001`
- Copy ngrok url to github configuration page (settings->webhooks)
`http://xxxxxxx.ngrok.io/api/v1/notifications_filter`
- Change CHANNEL in SlackNotificationService to your `@name` or `#some_test_channel`
- Create/edit pull request adding or removing labels. This will execute the webhook.## ActiveAdmin page
You can access the admin page at `http://localhost:3001/admin/users` and add users that you want to ignore## Deploy to Heroku
Install heroku cli https://devcenter.heroku.com/articles/heroku-cli#download-and-install
* Setup:
```
heroku login
enter credentials
heroku git:remote -a rootstrap-pull-request-to-slack
```* Push:
```
git push heroku master
```## Docs
#### Ngrok
Public URLs for exposing your local web server
https://ngrok.com/#### Github Hooks
Info about github hooks and Pull request payloadhttps://developer.github.com/webhooks/configuring/
https://developer.github.com/v3/activity/events/types/#pullrequestevent#### Slack methods
https://api.slack.com/methods## Contributing
Bug reports (please use Issues) and pull requests are welcome on GitHub at https://github.com/rootstrap/pull_requests_to_slack/issues. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.## License
The library is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).## Credits
Github for Slack is maintained by [Rootstrap](http://www.rootstrap.com) with the help of our [contributors](https://github.com/rootstrap/pull_requests_to_slack/contributors).[](http://www.rootstrap.com)