Slack & GitHub Integration: Get Commit Notifications for Specific Branches
This guide provides a straightforward process to install the GitHub app on your Slack workspace and configure it to receive real-time commit notifications for a specified branch of your GitHub repository. Stay updated on your team's development progress directly within your Slack channels.
This guide provides a straightforward process to install the GitHub app on your Slack workspace and configure it to receive real-time commit notifications for a specified branch of your GitHub repository. Stay updated on your team's development progress directly within your Slack channels.
Part 1: Install the GitHub App on Slack
-
Go to the GitHub Slack Integration Page: Open your web browser and navigate to https://slack.github.com/.
-
Add to Slack: Click on the "Add to Slack" button.
-
Authorize Slack: You'll be prompted to sign in to your Slack workspace and authorize the GitHub app to access it. Select the workspace where you want to add the integration and click "Authorize."
-
Connect GitHub Account: After authorizing Slack, you'll need to connect your GitHub account. Click "Connect GitHub account" and log in with your GitHub credentials.
-
Grant Permissions: Review the permissions the app requests (e.g., access to repositories, commit data, webhook events) and grant permission. It's recommended to share only the necessary information for security.
-
Configure in Slack: Once the app is installed, the GitHub app will send you a direct message in Slack with instructions on how to use the
/githubslash command.
Part 2: Subscribe to a Specified Branch for Commit Notifications
-
Go to the Desired Slack Channel: Open Slack and navigate to the channel where you want to receive GitHub commit notifications.
-
Subscribe to the Repository: In the Slack channel, type the following command to subscribe to a repository:
`/github subscribe username/reponame`
Replace username with the GitHub username or organization name and reponame with the name of the repository. For example: /github subscribe my-org/my-repo.
By default, this will subscribe you to notifications for issues, pull requests, commits on the default branch (usually main), releases, and deployments.
- Subscribe to Commits on a Specific Branch: To get commit notifications for a specified branch (not just the default branch), use the following command:
`/github subscribe username/reponame commits:branch_name`
Replace username/reponame with your repository details and branch_name with the specific branch you want to monitor. For example: /github subscribe my-org/my-repo commits:develop.
- To subscribe to all commits across all branches, you can use:
/github subscribe username/reponame commits:*
Important Notes:
-
Ensure you have the necessary permissions in both GitHub and Slack to perform these actions (e.g., administrator or owner roles).
-
You can customize notifications further using the
/github settingscommand, which allows you to enable or disable specific event types (e.g.,reviews,comments,branches). -
If you encounter issues, review your Slack logs or reauthorize GitHub access.
Another Useful Command
For every new branch starting with prefix to subscribe in Slack, use this command
`/github subscribe username/reponame commits:'prefix_branchname_*'`
So for each branch with common prefix will automatically be subscribed to slack notifications.
prefix_branchname_v_1_100
prefix_branchname_v1_101
prefix_branchname_v1_102 and so on...