Skip to content

Commit

Permalink
Merge pull request #17 from PaulSearcy/master
Browse files Browse the repository at this point in the history
Adding IconEmoji option
  • Loading branch information
mrrobot47 authored Feb 19, 2020
2 parents 8a36de0 + 2edb972 commit 061a1e4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ jobs:

By default, action is designed to run with minimal configuration but you can alter Slack notification using following environment variables:

Variable | Default | Purpose
---------------|-------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------
SLACK_CHANNEL | Set during Slack webhook creation | Specify Slack channel in which message needs to be sent
SLACK_USERNAME | `rtBot` | The name of the sender of the message. Does not need to be a "real" username
SLACK_ICON | ![rtBot Avatar](https://github.com/rtBot.png?size=32) | User/Bot icon shown with Slack message
SLACK_COLOR | `good` (green) | You can pass an RGB value like `#efefef` which would change color on left side vertical line of Slack message.
SLACK_MESSAGE | Generated from git commit message. | The main Slack message in attachment. It is advised not to override this.
SLACK_TITLE | Message | Title to use before main Slack message
Variable | Default | Purpose
------------------|-------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------
SLACK_CHANNEL | Set during Slack webhook creation | Specify Slack channel in which message needs to be sent
SLACK_USERNAME | `rtBot` | The name of the sender of the message. Does not need to be a "real" username
SLACK_ICON | ![rtBot Avatar](https://github.com/rtBot.png?size=32) | User/Bot icon shown with Slack message. It uses the URL supplied to this env variable to display the icon in slack message.
SLACK_ICON_EMOJI | - | User/Bot icon shown with Slack message, in case you do not wish to add a URL for slack icon as above, you can set slack emoji in this env variable. Example value: `:bell:` or any other valid slack emoji.
SLACK_COLOR | `good` (green) | You can pass an RGB value like `#efefef` which would change color on left side vertical line of Slack message.
SLACK_MESSAGE | Generated from git commit message. | The main Slack message in attachment. It is advised not to override this.
SLACK_TITLE | Message | Title to use before main Slack message.

You can see the action block with all variables as below:

Expand Down
30 changes: 16 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ import (
)

const (
EnvSlackWebhook = "SLACK_WEBHOOK"
EnvSlackIcon = "SLACK_ICON"
EnvSlackChannel = "SLACK_CHANNEL"
EnvSlackTitle = "SLACK_TITLE"
EnvSlackMessage = "SLACK_MESSAGE"
EnvSlackColor = "SLACK_COLOR"
EnvSlackUserName = "SLACK_USERNAME"
EnvGithubActor = "GITHUB_ACTOR"
EnvSiteName = "SITE_NAME"
EnvHostName = "HOST_NAME"
EnvDepolyPath = "DEPLOY_PATH"
EnvSlackWebhook = "SLACK_WEBHOOK"
EnvSlackIcon = "SLACK_ICON"
EnvSlackIconEmoji = "SLACK_ICON_EMOJI"
EnvSlackChannel = "SLACK_CHANNEL"
EnvSlackTitle = "SLACK_TITLE"
EnvSlackMessage = "SLACK_MESSAGE"
EnvSlackColor = "SLACK_COLOR"
EnvSlackUserName = "SLACK_USERNAME"
EnvGithubActor = "GITHUB_ACTOR"
EnvSiteName = "SITE_NAME"
EnvHostName = "HOST_NAME"
EnvDepolyPath = "DEPLOY_PATH"
)

type Webhook struct {
Expand Down Expand Up @@ -102,9 +103,10 @@ func main() {
}

msg := Webhook{
UserName: os.Getenv(EnvSlackUserName),
IconURL: os.Getenv(EnvSlackIcon),
Channel: os.Getenv(EnvSlackChannel),
UserName: os.Getenv(EnvSlackUserName),
IconURL: os.Getenv(EnvSlackIcon),
IconEmoji: os.Getenv(EnvSlackIconEmoji),
Channel: os.Getenv(EnvSlackChannel),
Attachments: []Attachment{
{
Fallback: envOr(EnvSlackMessage, "GITHUB_ACTION=" + os.Getenv("GITHUB_ACTION") + " \n GITHUB_ACTOR=" + os.Getenv("GITHUB_ACTOR") + " \n GITHUB_EVENT_NAME=" + os.Getenv("GITHUB_EVENT_NAME") + " \n GITHUB_REF=" + os.Getenv("GITHUB_REF") + " \n GITHUB_REPOSITORY=" + os.Getenv("GITHUB_REPOSITORY") + " \n GITHUB_WORKFLOW=" + os.Getenv("GITHUB_WORKFLOW")),
Expand Down

0 comments on commit 061a1e4

Please sign in to comment.