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.
- 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 admin@example.com:passwordnpm install -g ngrok
Install Ngrokrspec
and make sure all tests passrails s
- You are ready!
- 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.
You can access the admin page at http://localhost:3001/admin/users
and add users that you want to ignore
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
Public URLs for exposing your local web server https://ngrok.com/
Info about github hooks and Pull request payload
https://developer.github.com/webhooks/configuring/ https://developer.github.com/v3/activity/events/types/#pullrequestevent
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.
The library is available as open source under the terms of the MIT License.
Github for Slack is maintained by Rootstrap with the help of our contributors.