Skip to content

Commit

Permalink
Fix bug when Slack token is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
noraworld committed Jul 11, 2022
1 parent 7905e6a commit cef758b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions main
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ comment() {
}

post_to_slack() {
if [ "$SLACK_CHANNEL" = "" ] || [ "$SLACK_TOKEN" = "" ]; then
return
fi

# Do not indent in this section because extra spaces are interpolated to a Slack message
if $DEBUG; then
slack_message="
Expand All @@ -102,15 +106,13 @@ $(message slack)
"
fi

if [ "$SLACK_CHANNEL" != "" ] && [ "$SLACK_TOKEN" != "" ]; then
response=$(
curl \
-d "text=$slack_message " \
-d "channel=$SLACK_CHANNEL" \
-H "Authorization: Bearer $SLACK_TOKEN" \
-X POST https://slack.com/api/chat.postMessage
)
fi
response=$(
curl \
-d "text=$slack_message " \
-d "channel=$SLACK_CHANNEL" \
-H "Authorization: Bearer $SLACK_TOKEN" \
-X POST https://slack.com/api/chat.postMessage
)

ok=$(echo "$response" | jq -r .ok)

Expand Down

0 comments on commit cef758b

Please sign in to comment.