https://github.com/cainelli/stargazers-slack
:star2: A StdLib serverless function to notify GitHub Stargazers to Slack
https://github.com/cainelli/stargazers-slack
github serverless slack star stargazer stdlib
Last synced: about 2 months ago
JSON representation
:star2: A StdLib serverless function to notify GitHub Stargazers to Slack
- Host: GitHub
- URL: https://github.com/cainelli/stargazers-slack
- Owner: cainelli
- Created: 2017-08-29T00:47:22.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-31T23:48:15.000Z (almost 9 years ago)
- Last Synced: 2025-01-14T14:57:43.173Z (over 1 year ago)
- Topics: github, serverless, slack, star, stargazer, stdlib
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# StdLib Stargazers :star2: Slack
This is a [stdlib](https://stdlib.com) serverless function which recieves GitHub stars events and sends it to a [Slack](https://slack.com) channel.
https://www.useloom.com/share/881f7f3d6ed0437e8afab257374fd41d
## Slack
Login into your Slack account to configure a new [app](https://slack.com/apps). Search for `Incoming WebHooks` and then click in **Add Configuration**.

Choose a channel where the notifications will arrive and confirm it clicking in **Add Incoming WebHooks integration**.

Copy the **Webhook URL**, you will use it later in the app configuration. Click in **Save Settings**.

## StdLib
You need an __stdlib__ account and its CLI.
If you don’t have Node.js installed, download version v8.4.x or higher from the Node.js website. Once complete, open up your terminal and install the StdLib CLI.
```bash
$ npm install lib.cli -g
```
We need to create a directory for your StdLib services and initialize a workspace — you’ll be asked to log in with the account you already registered.
```bash
$ mkdir stdlib
$ cd stdlib
$ lib init
```
Once your workspace is initialized, you’re ready to create your StdLib service. Clone the repository
```bash
$ STDLIB_USER=$(lib user | grep username | awk '{print $2}')
$ git clone https://github.com/cainelli/stargazers-slack.git $STDLIB_USER/stargazers-slack
```
Update the `env.json` file with the proper information.
```json
{
"local": {},
"dev": {
"SLACK_WEBHOOK_URL": "https://hooks.slack.com/services/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",
"GITHUB_SECRET": "secret"
},
"release": {
"SLACK_WEBHOOK_URL": "https://hooks.slack.com/services/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",
"GITHUB_SECRET": "secret"
}
}
```
Finally you can start your dev environment running:
```bash
$ lib up dev
...
(default function)
------------------
url: https://cainelli.lib.id/stargazers-slack@dev/
code: lib.cainelli.stargazers-slack['@dev']()
shell: lib cainelli.stargazers-slack[@dev]
context: (enabled)
bg: info
```
The url above we will use to create GitHub webhook.
## GitHub
Go to the **Settings** of your project repository and then **Webhooks** and click in **Add Webhook**. Configure as following:
**Payload URL:** The URL above from the output of `lib up dev`.
**Content type:** application/json.
**Secret:** The `GITHUB_SECRET` environment variables defined in `env.json` file.
**Let me select individual events:** watch, fork.

Once you created the webhook you can :star2: star your repository and check on your Slack channel.
