pull_requests_to_slack
pull_requests_to_slack copied to clipboard
Send Github pull request notifications to Slack
Rootstrap Pull request to Slack
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
- Clone this repo
- Install PostgreSQL in case you don't have it
- Create your
database.yml
andapplication.yml
files. There are sample files in/config
-
bundle install
- Generate a secret key with
rake secret
and paste this value into theapplication.yml
. - Fill the
SLACK_API_TOKEN
andSLACK_BOT_TOKEN
inapplication.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 theOAuth Access Token
andSLACK_BOT_TOKEN
isBot User OAuth Access Token
-
rails db:create
-
rails db:migrate
-
rails db:seed
# this will create an admin with [email protected]:password -
npm install -g ngrok
Install Ngrok -
rspec
and make sure all tests pass -
rails s
- 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 payload
https://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 code of conduct.
License
The library is available as open source under the terms of the MIT License.
Credits
Github for Slack is maintained by Rootstrap with the help of our contributors.