Giter Site home page Giter Site logo

slack-notify's Introduction

Slack-Notify

Slack-Notify is a very simple tool for sending a Slack notification via a Slack Incoming Webhook.

It is designed to function as a 12-factor app, receiving configuration via environment variables. To keep things simple, it is rigid in what it allows you to set. More complex slackbots might want to customize this a little more.

Slack Incoming Webhooks

This tool uses Slack Incoming Webhooks to send a message to your slack channel.

Before you can use this tool, you need to log into your Slack account and configure this.

Usage

Running slack-notify in a shell prompt goes like this:

$ export SLACK_WEBHOOK=https://hooks.slack.com/services/Txxxxxx/Bxxxxxx/xxxxxxxx
$ SLACK_MESSAGE="hello" slack-notify

Running the Docker container goes like this:

$ export SLACK_WEBHOOK=https://hooks.slack.com/services/Txxxxxx/Bxxxxxx/xxxxxxxx
$ docker run -e SLACK_WEBHOOK=$SLACK_WEBHOOK -e SLACK_MESSAGE="hello" -e SLACK_CHANNEL=acid technosophos/slack-notify

In Brigade

You can easily use this inside of brigade hooks. Here is an example from hello-helm:

const {events, Job} = require("brigadier")

events.on("imagePush", (e, p) => {

  var slack = new Job("slack-notify", "technosophos/slack-notify:latest", ["/slack-notify"])

  // This doesn't need access to storage, so skip mounting to speed things up.
  slack.storage.enabled = false
  slack.env = {
    // It's best to store the slack webhook URL in a project's secrets.
    SLACK_WEBHOOK: p.secrets.SLACK_WEBHOOK,
    SLACK_USERNAME: "MyBot",
    SLACK_TITLE: "Message Title",
    SLACK_MESSAGE: "Message Body",
    SLACK_COLOR: "#0000ff"
  }
  slack.run()
})

Environment Variables

# The Slack-assigned webhook
SLACK_WEBHOOK=https://hooks.slack.com/services/Txxxxxx/Bxxxxxx/xxxxxxxx
# A URL to an icon
SLACK_ICON=http://example.com/icon.png
# The channel to send the message to (if omitted, use Slack-configured default)
SLACK_CHANNEL=example
# The title of the message
SLACK_TITLE="Hello World"
# The body of the message
SLACK_MESSAGE="Today is a fine day"
# RGB color to for message formatting. (Slack determines what is colored by this)
SLACK_COLOR="#efefef"
# The name of the sender of the message. Does not need to be a "real" username
SLACK_USERNAME"

Build It

Configure:

make bootstrap

Compile:

make build

Publish to DockerHub

make docker-build docker-push

slack-notify's People

Contributors

technosophos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.