Skip to content

Commit b0db758

Browse files
committed
add ignore-failure input
1 parent 2e3c1aa commit b0db758

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

action.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,23 @@ inputs:
2929
message-context:
3030
description: extra context information to be included with the notification message, usually displayed below the message
3131
required: true
32-
default: ''
32+
default: ""
3333
markdown:
3434
description: whether the message and message-context are in Slack’s Markdown format or not ("true" or "false" as string)
3535
required: true
36-
default: 'true'
36+
default: "true"
3737
replace-timestamp:
3838
description: the timestamp of a previously-sent message (e.g. from a previous step) to replace with this message
3939
required: true
40-
default: ''
40+
default: ""
4141
timeout:
4242
description: "how long to wait before giving up when sending notification to Slack (format: Go time.Duration)"
4343
required: true
4444
default: "30s"
45+
ignore-failure:
46+
description: "when true, the action will return success anyway upon failure to notify Slack"
47+
required: false
48+
default: "false"
4549
outputs:
4650
channel-id:
4751
description: the canonical channel ID where the message was sent

cmd/action-slack-notify/main.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ func main() {
4949
githubactions.Fatalf("timeout: time.ParseDuration: %s\n", err)
5050
}
5151

52+
ignoreFailureString := githubactions.GetInput("ignore-failure")
53+
ignoreFailure := ignoreFailureString == "true"
54+
5255
notifier := &slacknotifier.Notifier{
5356
BotUsername: botUsername,
5457
BotIconEmoji: botIconEmoji,
@@ -66,7 +69,11 @@ func main() {
6669
TimestampOfMessageToReplace: replaceMsgTimestamp,
6770
})
6871
if err != nil {
69-
githubactions.Fatalf("notifer.Notify: %s\n", err)
72+
if ignoreFailure {
73+
githubactions.Warningf("notifer.Notify: ignored error: %s\n", err)
74+
} else {
75+
githubactions.Fatalf("notifer.Notify: fatal: %s\n", err)
76+
}
7077
}
7178

7279
githubactions.SetOutput("channel-id", output.ChannelID)

0 commit comments

Comments
 (0)