Skip to content

Instantly share code, notes, and snippets.

@dslzuha
Last active April 21, 2020 23:07
Show Gist options
  • Save dslzuha/27b4c10f7debd4570e62ef78b4e25779 to your computer and use it in GitHub Desktop.
Save dslzuha/27b4c10f7debd4570e62ef78b4e25779 to your computer and use it in GitHub Desktop.
It's made by copy pest for all
# Slack Integration with GitHub
> **Heads Up!** The GitHub and Slack app has a few new features to help you turn conversations into next steps. Take action on pull requests, issues, and more right from your Slack channels to start moving work forward, faster. [Read more about it on the GitHub blog](https://blog.github.com/2018-05-17-new-improvements-to-slack-and-github-integration/).
## About
The GitHub integration for Slack gives you and your teams full visibility into your GitHub projects right in Slack channels, where you can generate ideas, triage issues and collaborate with other teams to move projects forward. This integration is an open source project, built and maintained by GitHub.
## Table of Contents
- [Installing the GitHub integration for Slack](#installing-the-github-integration-for-slack)
- [Requirements](#requirements)
- [Installation](#installation)
- [Authorization](#authorization)
- Getting Started
- [Repository Activity](#repository-activity)
- [Link previews](#link-previews)
- [Take action](#take-action)
- [Configuration](#configuration)
- [Migrating from the legacy GitHub integration for Slack](#migrating-from-the-legacy-github-integration-for-slack)
- [Need help?](#questions-need-help)
- [Contributing](#contributing)
- [License](#license)
--------
## Installing the GitHub integration for Slack
### Requirements
This app officially supports GitHub.com and Slack.com but the team plans to support GitHub Enterprise and Slack Enterprise Grid in the future.
### Installation
[Install the GitHub integration for Slack](https://slack.com/apps/A8GBNUWU8-github). After you've signed in to your Slack workspace, you will be prompted to give the app access:
<p align="center"><img width="450" alt="auth" src="https://user-images.githubusercontent.com/3877742/36522927-f1d596b6-1753-11e8-9f85-2495e657b16b.png"></p>
After the app is installed, and once you've added the GitHub integration to the relevant channels using `/invite @github`, you will see previews of links to GitHub issues, pull requests, and code rendered as rich text in your workspace.
<p align="center"><img width="550" alt="unfurl_convo" src="https://user-images.githubusercontent.com/3877742/36522313-c0cdbd08-1750-11e8-8dbe-b5a3a2f93549.png"></p>
### Subscribing and Unsubscribing
At this point, your Slack and GitHub user accounts are not linked. To link the two accounts, authenticate to GitHub using a `/github` slash command, `/github signin`.
The `/github` slash command also accepts a `subscribe` argument that you can use to subscribe to an Organization or Repository's activity `/github subscribe <organization>/<repository>`.
<p align="center"><img width="500" alt="unfurl_code" src="https://user-images.githubusercontent.com/3877742/36522323-ce7d4f36-1750-11e8-9eb2-b6f97c2d0053.png"></p>
If you originally gave the app access to "All repositories" and you've created a new private repository on GitHub after installing the GitHub integration for Slack, the `/github subscribe` command will work automatically on your new repository. If you installed the app on a subset of repositories, the app will prompt you to install it on the new repository.
The `/github` slash command also supports `unsubscribe`. To unsubscribe to notifications from a repository, use `/github unsubscribe <organization>/<repository>`
### Authorization
By granting the app access, you are providing the following authorizations to your GitHub and Slack accounts:
#### Slack Permission Scopes
|Permission scope|Why we need it|
|---|---|
|Access private conversations between you and the App | To message you with instructions. |
|View links to GitHub.com in messages| To render rich links from `github.com`|
|Add link previews to GitHub.com to messages| To render rich links to `github.com`|
|Add slash commands| To add the `/github` slash command to your Slack workspace |
|View the workspace or organization's name, email domain, and icon| To store subscriptions you set up|
|Post messages as the app| To notify you of activity that happens on GitHub, in Slack|
#### GitHub Permission Scopes
|Permission scope|Why we need it|
|---|---|
|Read access to code| To render code snippets in Slack|
|Read access to commit statuses, deployments, issues, metadata, pull requests, and repository projects | To render previews of links shared in Slack|
|Write access to issues and pull requests | To take action from Slack with the `/github` command and directly from messages|
#### Repository Activity
**Subscribe to an Organization or a Repository**
On repositories, the app notifies of `open`, `close`, and `re-open` events on pull requests and issues in repositories you've subscribed to. It also notifies of any `push` directly to the repository's default branch as well as `comments` on issues and pull requests.
#### Link previews
<!-- preserve old anchor in case other docs link there -->
<a name="types-of-public-link-unfurls"></a>
When a user posts a GitHub link to **issues and pull requests**, directly linked **comments**, code **blobs** with line numbers, as well as **organizations, repositories, and users** in Slack, a preview of the link will be shown.
Previews of links will not be shown if:
- link previews for `github.com` have been [disabled for your workspace](https://get.slack.help/hc/en-us/articles/204399343-Share-links-in-Slack#turn-off-link-previews-for-specific-sites)
- the same link was already shared in the last 30 minutes in the same channel
- 3 or more links are shared in the same chat message
- The repository is private and the user that shared the link:
- has not signed in to their GitHub account
- asked not to show a preview when prompted
- the GitHub app is not in the channel, which you can remedy with `/invite @github`
#### Take action here
Slack conversations often lead to decisions and actionable takeaways. Now it’s easier to start on next steps from Slack with slash commands for common GitHub actions, using `/github [action] [resource]`. These commands let you:
- Close an issue or pull request with `/github close [issue link]`
- Reopen an issue or pull request with `/github open [pull request link]`
- Open a new issue with `/github open [owner/repo]`
You can also take action on GitHub directly from a Slack message by clicking on the '`...` More Actions' menu available on every Slack message. From there you can:
- Attach a message as a comment to an existing issue or pull request
- Select an issue by choosing from an automatically loaded list of recently active issues and pull requests that involve you or by entering a URL to an issue or pull request
### Configuration
You can customize your notifications by subscribing to activity that is relevant to your Slack channel, and unsubscribing from activity that is less helpful to your project.
Settings are configured with the `/github` slash command:
```
/github subscribe owner/repo [feature]
/github unsubscribe owner/repo [feature]
```
These are enabled by default, and can be disabled with the `/github unsubscribe owner/repo [feature]` command:
- `issues` - Opened or closed issues
- `pulls` - New or merged pull requests
- `statuses` - Statuses on pull requests
- `commits` - New commits on the default branch (usually `master`)
- `deployments` - Updated status on deployments
- `public` - A repository switching from private to public
- `releases` - Published releases
These are disabled by default, and can be enabled with the `/github subscribe owner/repo [feature]` command:
- `reviews` - Pull request reviews
- `comments` - New comments on issues and pull requests
- `branches` - Created or deleted branches
- `commits:all` - All commits pushed to any branch
You can subscribe or unsubscribe from multiple settings at once. For example, to turn on activity for pull request reviews and comments:
```
/github subscribe owner/repo reviews comments
```
And to turn it back off:
```
/github unsubscribe owner/repo reviews comments
```
### Migrating from the legacy GitHub integration for Slack
When you install the new GitHub integration for Slack in your Slack workspace, you'll be prompted to move over all of your existing subscriptions - so getting set up again is easy. As you enable individual subscriptions in the new app, your settings will be automatically migrated and subscriptions in the legacy app will be disabled.
<p align="center"><img width="666" alt="migration" src="https://user-images.githubusercontent.com/3877742/36557399-ff8663c6-17bc-11e8-8962-d92088cf98a9.png"></p>
## Questions? Need help?
Please fill out GitHub's [Support form](https://github.com/contact?form%5Bsubject%5D=Re:+GitHub%2BSlack+Integration) and your request will be routed to the right team at GitHub.
## Contributing
Want to help improve the integration between GitHub and Slack? Check out the [contributing docs](CONTRIBUTING.md) to get involved.
## License
The project is available as open source under the terms of the [MIT License](LICENSE).
When using the GitHub logos, we should be sure to follow the [GitHub logo guidelines](https://github.com/logos).
@dslzuha
Copy link
Author

dslzuha commented May 25, 2019

@BdDsl Please Click here for sharing this Gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment