You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,10 +56,12 @@ SLACK_FOOTER | Powered By rtCamp's GitHub Actions Library | S
56
56
MSG_MINIMAL | - | If set to `true`, removes: `Ref`, `Event`, `Actions URL` and `Commit` from the message. You can optionally whitelist any of these 4 removed values by passing it comma separated to the variable instead of `true`. (ex: `MSG_MINIMAL: event` or `MSG_MINIMAL: ref,actions url`, etc.)
57
57
SLACKIFY_MARKDOWN | - | If set to `true`, it will convert markdown to slack format. (ex: `*bold*`to `bold`) Note: This only works for custom messages and not for the default message generated by the action. Credits: [slackify-markdown-action](https://github.com/marketplace/actions/slack-markdown-converter)
58
58
SLACK_THREAD_TS | - | If you want to send message in a thread, you can pass the timestamp of the parent message to this variable. You can get the timestamp of the parent message from the message URL in Slack. (ex: `SLACK_THREAD_TS: 1586130833.000100`)
59
+
SLACK_TOKEN | - | If you want to send message to a channel using a slack token. You will need to pass a channel in order to send messages using token, requiring a value for ``SLACK_CHANNEL``. Note that in case both webhook url and token are provided, webhook url will be prioritized.
59
60
SLACK_ON_SUCCESS | - | If set, will send the provided message instead of the default message when the passed status (through ``SLACK_COLOR``) is `success`.
60
61
SLACK_ON_FAILURE | - | If set, will send the provided message instead of the default message when the passed status (through ``SLACK_COLOR``) is `failure`.
61
62
SLACK_ON_CANCEL | - | If set, will send the provided message instead of the default message when the passed status (through ``SLACK_COLOR``) is `cancelled`.
62
63
SLACK_CUSTOM_PAYLOAD | - | If you want to send a custom payload to slack, you can pass it as a string to this variable. This will override all other variables and send the custom payload to slack. Example: `SLACK_CUSTOM_PAYLOAD: '{"text": "Hello, World!"}'`, Note: This payload should be in JSON format, and is not validated by the action.
64
+
ENABLE_ESCAPES | - | If set to `true`, will enable backslash escape sequences such as `\n`, `\t`, etc. in the message. Note: This only works for custom messages and not for the default message generated by the action.
63
65
64
66
65
67
You can see the action block with all variables as below:
Copy file name to clipboardExpand all lines: entrypoint.sh
+10-1Lines changed: 10 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
3
3
# Check required env variables
4
4
flag=0
5
+
mode="WEBHOOK"
5
6
if [[ -z"$SLACK_WEBHOOK" ]];then
6
7
flag=1
7
8
missing_secret="SLACK_WEBHOOK"
@@ -13,11 +14,19 @@ if [[ -z "$SLACK_WEBHOOK" ]]; then
13
14
fi
14
15
fi
15
16
17
+
if [[ "$flag"-eq 1 ]] && [[ -n"$SLACK_TOKEN"||-n"$SLACK_CHANNEL" ]] ;then
18
+
# Basically, if both SLACK_TOKEN and SLACK_CHANNEL are provided, then it's a token mode
19
+
flag=0
20
+
mode="TOKEN"
21
+
fi
22
+
16
23
if [[ "$flag"-eq 1 ]];then
17
-
printf"[\e[0;31mERROR\e[0m] Secret \`$missing_secret\` is missing. Please add it to this action for proper execution.\nRefer https://github.com/rtCamp/action-slack-notify for more information.\n"
24
+
echo -e "[\e[0;31mERROR\e[0m] Secret \`$missing_secret\` is missing. Alternatively, a pair of \`SLACK_TOKEN\` and \`SLACK_CHANNEL\` can be provided. Please add it to this action for proper execution.\nRefer https://github.com/rtCamp/action-slack-notify for more information.\n"
@@ -57,10 +61,14 @@ if [[ -n "$SITE_NAME" ]]; then
57
61
fi
58
62
59
63
60
-
if [[ -z"$SLACK_MESSAGE" ]];then
64
+
if [[ -z"$SLACK_MESSAGE"&&"null"!="$COMMIT_MESSAGE"]];then
61
65
SLACK_MESSAGE="$COMMIT_MESSAGE"
62
66
fi
63
67
68
+
if [[ -z"$SLACK_MESSAGE" ]];then
69
+
SLACK_MESSAGE="Notification from action run \`$GITHUB_RUN_NUMBER\`, which ran against commit \`${GITHUB_SHA}\` from branch \`${GITHUB_BRANCH}\` of \`${GITHUB_REPOSITORY}\` repository."
0 commit comments