sample
turbot/flowpipe-samples/notify-slack-new-github-release

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/tap
brew install flowpipe

Clone:

git clone https://github.com/turbot/flowpipe-samples.git
cd software_development/notify_slack_new_github_release

Install mod dependencies:

flowpipe mod install

Connections

By default, the following environment variables will be used for authentication:

  • SLACK_TOKEN

You can also create connection resources in configuration files:

vi ~/.flowpipe/config/slack.fpc
connection "slack" "default" {
token = "xoxp-12345-..."
}

For more information on connections in Flowpipe, please see Managing Connections.

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:

  1. Get the trigger details:
flowpipe trigger show http.github_webhook_release_events
  1. Copy the Url, e.g., /hook/github_webhook_release_events.trigger.http.github_webhook_release_events/92ffeda03426754f2c79dfaa
  2. 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
  1. 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
  2. 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.fpvars
vi flowpipe.fpvars
slack_channel = "test-channel"