Notify Slack for New GitHub Releases
Notify a Slack channel when a new GitHub release is published.
Installation
Download and install Flowpipe (https://flowpipe.io/downloads). Or use Brew:
brew tap turbot/tapbrew install flowpipe
Clone:
git clone https://github.com/turbot/flowpipe-samples.gitcd software_development/notify_slack_new_github_release
flowpipe mod install
Credentials
By default, the following environment variables will be used for authentication:
SLACK_TOKEN
You can also create credential
resources in configuration files:
vi ~/.flowpipe/config/slack.fpc
credential "slack" "default" { token = "xoxp-12345-..."}
For more information on credentials in Flowpipe, please see Managing Credentials.
Usage
To get notified in Slack when a new GitHub release is published, run:
flowpipe server
Once started, Flowpipe will run the pipeline automatically whenever a webhook event is received.
Configuration
To run the pipeline automatically whenever a webhook event is received, you can create a GitHub webhook subscription.
To configure the webhook subscription in GitHub:
- Get the trigger details:
flowpipe trigger show http.github_webhook_release_events
- Copy the
Url
, e.g.,/hook/github_webhook_release_events.trigger.http.github_webhook_release_events/92ffeda03426754f2c79dfaa
- Use a tool like ngrok with a custom domain to expose your localhost server to the internet:
ngrok http 7103 --domain=yellow-neutral-lab.ngrok-free.app
- Form the full webhook URL with the public endpoint from ngrok and the trigger URL using the format
https://{ngrok_domain}.ngrok-free.app/api/latest/{hook_url}
, e.g.,https://yellow-neutral-lab.ngrok-free.app/api/latest/hook/github_webhook_release_events.trigger.http.github_webhook_release_events/92ffeda03426754f2c79dfaa
- Create a webhook in the GitHub repository:
- Payload URL:
<URL from above>
- Content type:
application/json
- Secret: Can optionally add a secret
- Events:
Releases
- Active: Checked
To avoid entering variable values when running the pipeline or starting the server, you can set variable values:
cp flowpipe.fpvars.example flowpipe.fpvarsvi flowpipe.fpvars
slack_channel = "test-channel"