Skip to content

Commit

Permalink
Merge branch 'achandebois-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrrobot47 committed Nov 13, 2020
2 parents 12ca3c8 + ae95195 commit da06983
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ SLACK_COLOR | `good` (green) | You
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.
SLACK_FOOTER | Powered By rtCamp's GitHub Actions Library | Slack message footer.
MSG_MINIMAL | - | If set to true, removes: `Ref`, `Event` and `Actions URL` from the message.

MSG_MINIMAL | - | If set to `true`, removes: `Ref`, `Event` and `Actions URL` from the message. You can optionally whitelist any of these 3 removed values by passing it comma separated to the variable instead of `true`. (ex: `MSG_MINIMAL: event` or `MSG_MINIMAL: ref,actions url`, etc.)

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

Expand Down
42 changes: 42 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"os"
"strings"
)

const (
Expand Down Expand Up @@ -74,6 +75,47 @@ func main() {
},
}
fields = append(mainFields, fields...)
} else if minimal != "" {
requiredFields := strings.Split(minimal, ",")
mainFields := []Field{
{
Title: os.Getenv(EnvSlackTitle),
Value: envOr(EnvSlackMessage, "EOM"),
Short: false,
},
}
for _,requiredField := range requiredFields {
switch strings.ToLower(requiredField) {
case "ref":
field := []Field{
{
Title: "Ref",
Value: os.Getenv("GITHUB_REF"),
Short: true,
},
}
mainFields = append(field, mainFields...)
case "event":
field := []Field{
{
Title: "Event",
Value: os.Getenv("GITHUB_EVENT_NAME"),
Short: true,
},
}
mainFields = append(field, mainFields...)
case "actions url":
field := []Field{
{
Title: "Actions URL",
Value: "https://github.com/" + os.Getenv("GITHUB_REPOSITORY") + "/commit/" + os.Getenv("GITHUB_SHA") + "/checks",
Short: false,
},
}
mainFields = append(field, mainFields...)
}
}
fields = append(mainFields, fields...)
} else {
mainFields := []Field{
{
Expand Down

0 comments on commit da06983

Please sign in to comment.